Skip to main content

Native Functions Reference

Comprehensive reference for all FiveM/GTA5 native functions available through the @true_life/swc-plugin-native-inliner build plugin.

Interactive Browser

For a searchable, filterable native browser similar to FiveM's native docs, visit the Native Reference Browser.

Overview

The True Life framework provides access to 7,571 native functions across 46 namespaces. These natives are automatically inlined at build time by the SWC plugin, providing:

  • Zero-cost abstraction - Native calls are compiled to direct Citizen.invokeNative() calls
  • Type safety - Full TypeScript definitions via @true_life/natives-client and @true_life/natives-server
  • Platform filtering - Only relevant natives are included per build target

Platform Availability

PlatformNative CountDescription
Client7,216GTA5 game natives (graphics, physics, entities, etc.)
Server281CFX server-side natives (player management, resources)
Both74Shared natives available on both platforms

Build Configuration

The native inliner is configured in the Rollup build:

// tools/rollup-config.js
const swcPlugins = [
	[
		SWC_PLUGINS.nativeInliner,
		{
			platform: environment, // "client" or "server"
			addComments: true, // Add debug comments showing original native
		},
	],
];

Plugin Options

OptionTypeDefaultDescription
platform"Client" | "Server""Client"Filter natives by platform
addCommentsbooleantrueAdd comments showing original native name

Type Definitions

Install the appropriate type definitions package:

# For client-side natives
pnpm add -D @true_life/natives-client
 
# For server-side natives
pnpm add -D @true_life/natives-server

Reference in your TypeScript files:

/// <reference types="@true_life/natives-client" />
 
// Full type safety for all natives
const playerPed = GetPlayerPed(-1);
const coords = GetEntityCoords(playerPed, false);

Namespace Reference

Summary by Category

CategoryNamespacesDescription
CoreCFX, BUILTIN, MISCFramework and utility functions
EntitiesENTITY, PED, VEHICLE, OBJECTGame world entities
PlayerPLAYER, PADPlayer state and input
WorldINTERIOR, WATER, ZONE, FIREEnvironment and world state
GraphicsGRAPHICS, CAM, HUDRendering, cameras, UI
AudioAUDIOSound and music
NetworkNETWORK, SOCIALCLUB, LOBBYMultiplayer and social
GameplayTASK, WEAPON, PHYSICS, PATHFINDGame mechanics
DataSTATS, DATAFILE, DECORATORPersistent data
SystemSCRIPT, STREAMING, CLOCK, EVENTResource management

Detailed Namespace Counts

NamespaceCountPlatformDescription
CFX898BothCitizenFX framework natives
NETWORK878ClientNetworking and synchronization
VEHICLE779ClientVehicle manipulation
PED615ClientPedestrian/NPC control
HUD519ClientUI elements and notifications
GRAPHICS401ClientRendering and visual effects
MONEY356ClientEconomy system
MISC334ClientMiscellaneous utilities
STATS333ClientStatistics tracking
TASK313ClientAI task system
AUDIO281ClientSound and music
PLAYER250ClientPlayer state
CAM248ClientCamera control
ENTITY189ClientEntity base functions
OBJECT166ClientWorld objects/props
WEAPON123ClientWeapons and combat
STREAMING123ClientAsset streaming
SOCIALCLUB84ClientSocial Club integration
PATHFIND60ClientNavigation and pathfinding
DATAFILE57ClientData file operations
CUTSCENE56ClientCutscene playback
PAD50ClientController/keyboard input
PHYSICS49ClientPhysics simulation
EXTRAMETADATA49ClientExtra metadata
INTERIOR45ClientInterior spaces
NETSHOPPING41ClientOnline shop
SCRIPT37ClientScript management
BUILTIN26BothBuilt-in functions
MOBILE25ClientPhone UI
FIRE21ClientFire/explosion effects
RECORDING17ClientRecording/replay
APP17ClientApp integration
CLOCK16ClientTime management
EVENT13ClientGame events
WATER12ClientWater simulation
DECORATOR12ClientEntity decorators
SHAPETEST11ClientRaycasting/collision
DLC11ClientDLC content
BRAIN11ClientAI behavior
ZONE9ClientMap zones
ITEMSET9ClientItem collections
LOBBY8ClientLobby management
SAVEMIGRATION7ClientSave data migration
REPLAY6ClientReplay system
SECURITY3ClientSecurity functions
LOCALIZATION3ClientLocalization

Data Types

Parameter Types

TypeTypeScriptDescription
intnumberInteger value
floatnumberFloating-point value
boolbooleanBoolean value
stringstringString value
hashnumberJOAAT hash (use joaat() helper)
entitynumberEntity handle
pednumberPedestrian entity handle
vehiclenumberVehicle entity handle
objectnumberWorld object handle
playernumberPlayer index
blipnumberBlip handle
camnumberCamera handle
pickupnumberPickup handle
interiornumberInterior handle
fire_idnumberFire effect handle
scr_handlenumberScript handle
vector3[number, number, number]3D vector
tableobjectLua table (object)
anyunknownAny type
functionFunctionCallback function

Return Types

TypeTypeScriptDescription
voidvoidNo return value
mut_stringstringMutable string (output parameter)
longnumber64-bit integer

Usage Examples

Entity Manipulation

"use client";
 
// Get player ped and coordinates
const playerPed = GetPlayerPed(-1);
const [x, y, z] = GetEntityCoords(playerPed, true);
 
// Teleport entity
SetEntityCoords(playerPed, 100.0, 200.0, 30.0, false, false, false, false);
 
// Check entity state
if (IsEntityDead(playerPed)) {
	console.log("Player is dead");
}
 
// Entity health
const health = GetEntityHealth(playerPed);
SetEntityHealth(playerPed, 200);

Vehicle Operations

"use client";
 
// Spawn a vehicle
const model = joaat("adder");
RequestModel(model);
 
// Wait for model to load
while (!HasModelLoaded(model)) {
	await new Promise((r) => setTimeout(r, 0));
}
 
const [x, y, z] = GetEntityCoords(GetPlayerPed(-1), true);
const vehicle = CreateVehicle(model, x, y, z, 0.0, true, false);
 
// Set vehicle properties
SetVehicleColours(vehicle, 12, 12);
SetVehicleNumberPlateText(vehicle, "TRUELIFE");
SetVehicleEngineOn(vehicle, true, true, false);

Ped Control

"use client";
 
// Create a ped
const model = joaat("a_m_y_hipster_01");
RequestModel(model);
while (!HasModelLoaded(model)) {
	await new Promise((r) => setTimeout(r, 0));
}
 
const [x, y, z] = GetEntityCoords(GetPlayerPed(-1), true);
const ped = CreatePed(4, model, x + 2, y, z, 0.0, true, true);
 
// Give weapon
GiveWeaponToPed(ped, joaat("WEAPON_PISTOL"), 100, false, true);
 
// Task ped to wander
TaskWanderStandard(ped, 10.0, 10);
 
// Set ped appearance
SetPedComponentVariation(ped, 0, 0, 0, 0);

Camera Control

"use client";
 
// Create scripted camera
const cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true);
const [x, y, z] = GetEntityCoords(GetPlayerPed(-1), true);
 
SetCamCoord(cam, x, y, z + 10);
PointCamAtCoord(cam, x, y, z);
SetCamActive(cam, true);
RenderScriptCams(true, true, 1000, true, false);
 
// Cleanup
await new Promise((r) => setTimeout(r, 5000));
RenderScriptCams(false, true, 1000, true, false);
DestroyCam(cam, false);

HUD and Notifications

"use client";
 
// Show notification
BeginTextCommandThefeedPost("STRING");
AddTextComponentSubstringPlayerName("Hello from True Life!");
EndTextCommandThefeedPostTicker(false, false);
 
// Draw text on screen
SetTextFont(4);
SetTextScale(0.5, 0.5);
SetTextColour(255, 255, 255, 255);
SetTextCentre(true);
BeginTextCommandDisplayText("STRING");
AddTextComponentSubstringPlayerName("On-screen text");
EndTextCommandDisplayText(0.5, 0.5);

Server-Side Natives

"use server";
 
// Get connected players
const players = GetPlayers();
const playerCount = GetNumPlayerIndices();
 
// Get player identifiers
for (const player of players) {
	const name = GetPlayerName(player);
	const identifiers = getPlayerIdentifiers(player);
	console.log(`Player: ${name}`, identifiers);
}
 
// Kick player
DropPlayer(playerId, "Reason for kick");

Using with Entity Classes

The framework provides wrapper classes that abstract native calls:

"use client";
 
import { Player, Ped, Vehicle, vec3 } from "@core/classes";
 
// Instead of: GetPlayerPed(-1)
const player = Player.LOCAL;
const ped = player.ped;
 
// Instead of: GetEntityCoords(handle, true)
const pos = ped.coords;
 
// Instead of: SetEntityCoords(handle, x, y, z, ...)
ped.coords = vec3(100, 200, 30);
 
// Instead of: GetEntityHealth(handle)
const health = ped.health;

See Entity Classes for the full API.

JOAAT Hash Helper

Many natives require hash values. Use the joaat() helper:

// Compile-time hash (optimized by swc-plugin-joaat)
const modelHash = joaat("adder");
 
// Equivalent to calling GetHashKey at runtime, but faster
RequestModel(modelHash);

The joaat() calls with string literals are replaced at build time with their computed hash values.

CFX-Specific Natives

CFX (CitizenFX) provides additional natives beyond GTA5:

State Bags

// Server-side
const bag = Player(playerId).state;
bag.customData = { score: 100 };
 
// Check if key exists
if (StateBagHasKey("player:" + playerId, "customData")) {
	const data = bag.customData;
}

DUI (Direct UI)

"use client";
 
// Create browser texture
const duiObj = CreateDui("https://example.com", 1280, 720);
const duiHandle = GetDuiHandle(duiObj);
 
// Use in-game on a runtime texture
CreateRuntimeTextureFromDuiHandle(txd, "browser", duiHandle);

Resource KVP

// Set key-value
SetResourceKvp("player_settings", JSON.stringify({ volume: 0.8 }));
 
// Get key-value
const settings = GetResourceKvpString("player_settings");

External References

Package Information

PackageDescription
@true_life/swc-plugin-native-inlinerSWC plugin for native call inlining
@true_life/natives-clientTypeScript definitions for client natives
@true_life/natives-serverTypeScript definitions for server natives
@true_life/natives-commonShared native utilities