[BUG/BROKEN] Obtaining Nearby/Any/All Vehicles

The following Natives don’t seem to work:

  1. IS_ANY_VEHICLE_NEAR_POINT -> always 0
  2. GET_CLOSEST_VEHICLE - always -1

As well as the Lua call GetClosestVehicle

After some research into the Citizinfx I’ve found the following:
https://github.com/citizenfx/fivem/blob/master/client/clrcore/External/World.cs#L693

But as you can see it is ‘commented out’, but I’m wondering why?
Since FiveM most likely tracks all vehicles in the server anyway for sync purpose.

Does anyone had something working with searching/finding vehicles, please feel free to share.

1 Like

Up !

This functions are really important if you want code in c#

Any Idea when its implemented ?

GetClosestVehicle() works in Lua, I’ve used it.

local playerPos = GetEntityCoords(GetPlayerPed(-1))
local closestVehicle = GetClosestVehicle(playerPos.x, playerPos.y, playerPos.z, 5.0, 0, 23)

Me too, for my script for boat shop and docks I have used closestvehicle

GetNearby has been disabled and I don’t know why fivem developpers have decided this

From what I can tell it’s because it didn’t work in a networked game. Single player only function I’d guess?

It hasn’t been ‘disabled’, it hasn’t ever been enabled because the backing native is using an unusual calling convention (in case of Lua) or was written in C++/CLI (in case of C#).

Stop expecting every single feature you’re used to from V itself to work, and stop making up random theories as to things intentionally being ‘disabled’.

No? It’d work fine to get any entities that were cloned to the local client, however eventually proper pool iteration natives will be created.

1 Like

It’s listed as a native, it’s in the fivem client scripting dump, is able to be called, it’s not weird to wonder why it doesn’t work. Stop expecting natives to work? Uh okay.

Allpeds and allvehs will be added. They just haven’t been rewritten yet.