Any way to determine existence of car with particular plate on server?

Hi there everyone!

Is there a way to determine whether a driveable vehicle exists on the server or barring that, at least in a surrounding area?

I don’t think the server knows anything about vehicles?

Maybe you could have it trigger a client event which would report back all nearby vehicles for each player and then search through those results?

Otherwise, you’d have to start tracking vehicles on the server, by having clients report when they’re spawned/de-spawned and report position, etc periodically (don’t do this too frequently, for performance reasons).

Thanks very much for the help, numbers and letters!

How would I scan the player’s area for a vehicle with particular tag? Perhaps there’s a resource I could look at for this?

Sure, sorry I thought I mentioned/ check out FindFirstVehicle/FindNextVehicle, you can search forums for examples.

And to check area this should do the trick, IsEntityInArea
although … I’m not sure if that will work server side

You might have to just do an old fashioned distance calculation between the vehicle coordinates and the center point of whatever area you want to search and test if it’s less than some radius, if you want to it server side.

function distance ( x1, y1, x2, y2 )
local dx = x1 - x2
local dy = y1 - y2
return math.sqrt ( dx * dx + dy * dy )

Or, it’s typically called magnitude, on vectors. So you could try (center_position - vehicle_position).magnitude

though I’m not sure if the FiveM Lua Vector3 supports this method.

Thanks a bunch for the names of the functions. I’ll do some file searches and see if I can find an example close enough to modify for my needs.

Thanks again!