shared
vector3 / vector4
FiveM shared native documentation with a Lua example.
Summary
Native vector types for positions (vector3) and positions+heading (vector4). Enable cheap distance math with the # operator.
Returns
vector
Example
local pos = vector3(200.0, -1000.0, 30.0)
local spawn = vector4(200.0, -1000.0, 30.0, 90.0) -- x,y,z,heading
local dist = #(GetEntityCoords(PlayerPedId()) - pos)Common pitfalls
- #(a - b) is the fast idiomatic distance check — prefer it in loops.
- vector4 carries heading, handy for spawn points.
- Access components with .x .y .z (.w for heading).
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 →