Check does entity exists


#1

How can I check does entity exists by coords with radius?


#2

You want to know if a specific entity is within a specific radius of some coords?

Vdist() or Vdist2() will be perfect for that.https://runtime.fivem.net/doc/reference.html#_0x2A488C176D52CCA5
https://runtime.fivem.net/doc/reference.html#_0xB7A628320EFF8E47


#3

Yep that’s what I wanted to do. But natives that you’ve provided need 2 xyz. I need something that will check by 1 xyz and radius.


#4

One of those coordinates should be your target coordinates (the one you want to check distance from). Then the others should be the coordinates of your entity, so like this:

local ped = PlayerPedId()
local radius = 50.0
local entityCoords = GetEntityCoords(ped, true)
local distance = Vdist(<some target coords here>, entityCoords)

if distance <= radius then
    -- entity is within the radius
else
    -- entity is outside the radius
end