FiveM Natives Reference
FiveM natives are functions exposed by GTA V or the Cfx.re runtime. Use them to read and change entities, players, vehicles, cameras, controls, graphics, and other game systems.
This page is a practical starting point for the most common natives. For every available function, parameter, return type, hash, and API set, use the official Cfx.re native reference .
Find the right native
Before copying a native into a resource, check three things:
| Check | Why it matters |
|---|---|
| API set | A native may be client-only, server-only, or available in both contexts. |
| Signature | Parameters and return values can differ between similarly named functions. |
| Entity ownership | A valid network ID does not guarantee that the current client controls the entity. |
Native names are case-insensitive in the official search, so queries such as
GetEntityCoords, GET_ENTITY_COORDS, and the native hash lead to the same
reference entry.
Common player and entity natives
Get the local player ped
PlayerPedId is a client-side native. It returns the ped entity for the player
running the client script.
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
print(('Player coordinates: %.2f, %.2f, %.2f'):format(
coords.x,
coords.y,
coords.z
))On the server, use the player’s server ID with GetPlayerPed instead:
local function getPlayerPosition(playerSource)
local ped = GetPlayerPed(playerSource)
if ped == 0 then
return nil
end
return GetEntityCoords(ped)
endCheck whether an entity exists
Entity handles can become invalid when an entity is deleted or leaves scope. Check the handle before reading or changing it:
if entity ~= 0 and DoesEntityExist(entity) then
local coords = GetEntityCoords(entity)
endSpawn a vehicle safely
Client-side model creation should request the model, wait with a timeout, create the entity, and then release the model from the script’s model list.
local function loadModel(model, timeoutMs)
if not IsModelInCdimage(model) or not IsModelAVehicle(model) then
return false
end
RequestModel(model)
local deadline = GetGameTimer() + timeoutMs
while not HasModelLoaded(model) do
if GetGameTimer() >= deadline then
return false
end
Wait(0)
end
return true
end
local model = `adder`
if loadModel(model, 5000) then
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local heading = GetEntityHeading(ped)
local vehicle = CreateVehicle(
model,
coords.x,
coords.y,
coords.z,
heading,
true,
false
)
SetPedIntoVehicle(ped, vehicle, -1)
SetModelAsNoLongerNeeded(model)
endFor persistent networked vehicles, create and authorize them through trusted server logic instead of accepting an arbitrary model from a client event.
Controls and drawing
Drawing natives must run every frame while the element is visible. Input checks that depend on a disabled control must use the corresponding disabled-control native.
local markerCoords = vector3(215.0, -810.0, 30.0)
CreateThread(function()
while true do
local sleep = 1000
local playerCoords = GetEntityCoords(PlayerPedId())
local distance = #(playerCoords - markerCoords)
if distance < 30.0 then
sleep = 0
DrawMarker(
1,
markerCoords.x,
markerCoords.y,
markerCoords.z - 1.0,
0.0, 0.0, 0.0,
0.0, 0.0, 0.0,
1.0, 1.0, 1.0,
80, 160, 255, 180,
false, false, 2, false,
nil, nil, false
)
if distance < 1.5 and IsControlJustReleased(0, 38) then
print('Interacted with marker')
end
end
Wait(sleep)
end
end)See the searchable control IDs and marker types for the values used by these natives.
Native usage by language
Most named natives are exposed through the runtime wrapper for each supported language:
-- Lua
local coords = GetEntityCoords(PlayerPedId())// JavaScript
const coords = GetEntityCoords(PlayerPedId());// C#
Vector3 coords = API.GetEntityCoords(API.PlayerPedId(), true);Always confirm the language-specific signature in the official reference. Do not translate parameter types by guesswork.
Performance rules
- Cache values that do not need to be recalculated every frame.
- Use
Wait(0)only for work that must render or check input each frame. - Increase the wait time when the player is far from an interaction.
- Use Lua vector math such as
#(a - b)for straightforward distance checks. - Prefer compile-time hashes such as
`adder`for constant model names. - Avoid broadcasting network events when only one client needs the result.
Use resmon and the FiveM profiler to measure the resource instead of assuming a native is slow.