From the reference libraryRedM

Calling RedM/RDR3 natives from Lua

guides/invoke_lua.md

Calling RedM/RDR3 natives from Lua

Quick reference. Native doc pages already contain Lua examples — this is the meta-guide.

Two forms

-- Direct (wrapper) — preferred when the wrapper exists
local ped = GetPlayerPed(-1)

-- Hash form — works for every native, required if no wrapper
local ped = Citizen.InvokeNative(0x275F255ED201B937, -1)

Note: capital I in Citizen.InvokeNative (Lua), lowercase i in Citizen.invokeNative (JS).

Return values

Lua handles return types automatically — no result modifiers needed. The native returns whatever its declared return type is.

local heading = GetEntityHeading(entity)        -- float
local coords = GetEntityCoords(entity, true)    -- vector3 (coords.x, coords.y, coords.z)
local name = GetEntityModel(entity)             -- string or hash depending on native

Argument types

Native param Lua arg
int, BOOL, Hash, Entity, Ped, Vehicle number
float number (Lua has no separate float)
const char* string
Vector3 arg Pass three numbers x, y, z — same as JS
Hash from name GetHashKey('model_name') or `model_name` (backtick literal, RedM/FiveM-specific)

Output pointers

Lua makes pointer outputs ergonomic — they're returned as additional return values:

local hit, groundZ = GetGroundZFor_3dCoord(x, y, z, false)

Multiple *-args become extra return values in the order they appear in the C signature.

BOOL

Lua BOOL is returned as a Lua boolean (true/false), unlike JS where it comes back as 0/1.

Backtick hash literal

RedM/FiveM Lua extends the syntax with backtick string literals that are compile-time hashed:

local hash = `a_c_horse_americanstandard_black` -- equivalent to GetHashKey(...)

When to use Hash form

  • Native is too new for the runtime's wrapper list (rare nowadays).
  • You're loading a hash dynamically.
  • You want to be explicit about which exact native variant you're calling.

Otherwise, prefer the Direct form — the wrappers handle output-pointer unwrapping and type coercion for you.

Backtick hash literal

RedM/FiveM Lua extends the syntax with backtick string literals that are compile-time hashed:

local hash = `some_model_name` -- equivalent to GetHashKey('some_model_name')
Back to documentation