client
GetEntityCoords
FiveM client native documentation with a Lua example.
Summary
Returns the world coordinates (vector3) of any entity — ped, vehicle, or object.
Returns
vector3 — the entity's X, Y, Z position.
Parameters
entitynumberThe entity handle (ped, vehicle, or object).alivebooleanOptional. Whether to only return coords if the entity is alive.Example
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
print(coords.x, coords.y, coords.z)
-- Distance check between player and a point
local target = vector3(-254.1, -971.4, 31.2)
if #(coords - target) < 2.0 then
-- player is within 2.0 units
endCommon pitfalls
- Using #(a - b) for distance is far cheaper than GetDistanceBetweenCoords — prefer it in loops.
- Don't run this every frame with no Wait() — it's a common cause of server lag.
Related natives
Related guides
Need protected areas on your map?
Viper Safe-Zone draws polygon safe zones in-game — no hand-edited coordinates — with weapon, combat and vehicle-speed rules per zone.
See Viper Safe-Zone →