Anyone found out yet how to get these natives to work in FiveReborn?
Like that, for example:
local pos = GetEntityCoords(GetPlayerPed(-1)) local rped = GetRandomPedAtCoord(pos['x'], pos['y'], pos['z'], 20.05, 20.05, 20.05, 6, _r) local rped2 = GetClosestPed(pos['x'], pos['y'], pos['z'], 20.05, 1, 0, 0, 0, -1) if DoesEntityExist(rped) then -- do something here end if DoesEntityExist(rped2) then -- do something here end
Did you test this? …
yes. it is works. GetRandomPedAtCoord - 100% works. Return peds who do not stay, do not flee and do not panic. Just walking peds, or peds who want to cross the roads. In short time i release some scripts with examples.
I dont wanna get one single pad, i want all in a certain area like GetPedNearbyPeds does. In other Scriptling Languages it seems to work fine, but in LUA, especially FiveReborn idk how to use it.
did you try to pack it in table?
GET_PED_NEARBY_VEHICLES returns array, where  is size of it. Which is convenient for C-like languages. But in lua arrays and tables are same strange substance consisting of pointers you can’t see and work with directly. So I need C-Lua workaroud for that. Right? Maybe I should create small DLL with one function which will call GET_PED_NEARBY_VEHICLES, do what I wanted to do with this array(find best vehicle for my crew to get in), free() it (what allocator it use?) and return one result. But it’s also possible to form lua array from it using C code, right? Why we don’t already have that in natives_5794n93num63r5.lua?
Because these natives are two special cases that would provide a burden on script runtimes and aren’t needed given how there’s FIND_FIRST_VEHICLE/FIND_NEXT_VEHICLE/END_FIND_VEHICLE?
See this guy’s example.
Don’t you think that looking for NEARBY vehicles with native code is faster than iterating ALL vehicles and comparing distances with lua?
Do you think that matters? Oh wait, you seem to feel smarter than our development team anyway.
You feel smarter than RAGE development team who definitely used search tree in GET_CLOSEST_* functions? If so, why you are making FiveM for RAGE instead of making better engine? No offence. I guess it’s same tree as used for collisions and it should be the fastest way to find closest entities. You don’t need to waste time rebuilding or balancing it or whatever, game is doing it already. How many entities can simultaneously exist in full session? What if I want to find closest entities for many points at the same time?
nah, they however just cache a literal set of ‘nearby’ peds. either way, the difference can be measured in microseconds and is completely irrelevant.
then Lua is going to be faster than a lot of calls to this native as you can specify arbitrary points without having to find a ped that has this data scanned already.
on that note, GET_CLOSEST_PED actually is a literal linear pool scan like these natives and therefore probably slower than GET_PED_NEARBY_PEDS, lol.
How many entities can simultaneously exist in full session?