Hello all! Ok, so I have a potentially big ask now…
What I want to have happen at the end of this, is when a vehicle that is stored in a table enters a certain radius within the world, it sends a chat message to the entire server.
I’m happy with any response, but the best thing really is a working example that I can learn from, that’s how I learn really. Thank you for reading this
In Lua, I’m not sure. I know that there are natives like Vdist2() and GetDistanceBetweenCoords() but doing it without a native is faster. Something like:
if (Vdist2(posX, posY, posZ, carX, carY, carZ) < 3) then
-- do something
end
I’d considered doing this, but came across two problems…
I want it to constantly be checking whether any vehicle within a table is in the specified radius of the coordinates, which are for an ANPR camera. But, my main concern is performance and if i’m getting the location of a vehicle in the world and attempting to determine whether it’s in the vicinity of these other coordinates, requiring it to be stored in a variable that needs to be updated every now and then would surely cause performance issues? Especially considering there’s going to be multiple zones and multiple vehicles to check.
And my second issue is I have no idea how exactly i’d get the location of the vehicles in the table. I check the natives and couldn’t find anything in regards to position of a vehicle by it’s hash or anything, only positioning of a player.
in LUA i use the id returned from creating the vehicle to locate and delete when needed. I am assuming this is its netID but i could be wrong. Either way, it works to return location, accepts entity functions from native.
As per performance i am runnning a huge radial scan on objects and peds, with tables holding upto 1000+ entries at times. “in seperate threads of course”. I have not seen an impact in performance as of yet.
If you are tracking 32 cars in a table, just loop about every quarter of a second, total round would be around 8 seconds give or take a few server ticks.