Native Functions Reference
Comprehensive reference for all FiveM/GTA5 native functions available through the @true_life/swc-plugin-native-inliner build plugin.
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-clientand@true_life/natives-server - Platform filtering - Only relevant natives are included per build target
Platform Availability
| Platform | Native Count | Description |
|---|---|---|
| Client | 7,216 | GTA5 game natives (graphics, physics, entities, etc.) |
| Server | 281 | CFX server-side natives (player management, resources) |
| Both | 74 | Shared 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
| Option | Type | Default | Description |
|---|---|---|---|
platform | "Client" | "Server" | "Client" | Filter natives by platform |
addComments | boolean | true | Add 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-serverReference 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
| Category | Namespaces | Description |
|---|---|---|
| Core | CFX, BUILTIN, MISC | Framework and utility functions |
| Entities | ENTITY, PED, VEHICLE, OBJECT | Game world entities |
| Player | PLAYER, PAD | Player state and input |
| World | INTERIOR, WATER, ZONE, FIRE | Environment and world state |
| Graphics | GRAPHICS, CAM, HUD | Rendering, cameras, UI |
| Audio | AUDIO | Sound and music |
| Network | NETWORK, SOCIALCLUB, LOBBY | Multiplayer and social |
| Gameplay | TASK, WEAPON, PHYSICS, PATHFIND | Game mechanics |
| Data | STATS, DATAFILE, DECORATOR | Persistent data |
| System | SCRIPT, STREAMING, CLOCK, EVENT | Resource management |
Detailed Namespace Counts
| Namespace | Count | Platform | Description |
|---|---|---|---|
| CFX | 898 | Both | CitizenFX framework natives |
| NETWORK | 878 | Client | Networking and synchronization |
| VEHICLE | 779 | Client | Vehicle manipulation |
| PED | 615 | Client | Pedestrian/NPC control |
| HUD | 519 | Client | UI elements and notifications |
| GRAPHICS | 401 | Client | Rendering and visual effects |
| MONEY | 356 | Client | Economy system |
| MISC | 334 | Client | Miscellaneous utilities |
| STATS | 333 | Client | Statistics tracking |
| TASK | 313 | Client | AI task system |
| AUDIO | 281 | Client | Sound and music |
| PLAYER | 250 | Client | Player state |
| CAM | 248 | Client | Camera control |
| ENTITY | 189 | Client | Entity base functions |
| OBJECT | 166 | Client | World objects/props |
| WEAPON | 123 | Client | Weapons and combat |
| STREAMING | 123 | Client | Asset streaming |
| SOCIALCLUB | 84 | Client | Social Club integration |
| PATHFIND | 60 | Client | Navigation and pathfinding |
| DATAFILE | 57 | Client | Data file operations |
| CUTSCENE | 56 | Client | Cutscene playback |
| PAD | 50 | Client | Controller/keyboard input |
| PHYSICS | 49 | Client | Physics simulation |
| EXTRAMETADATA | 49 | Client | Extra metadata |
| INTERIOR | 45 | Client | Interior spaces |
| NETSHOPPING | 41 | Client | Online shop |
| SCRIPT | 37 | Client | Script management |
| BUILTIN | 26 | Both | Built-in functions |
| MOBILE | 25 | Client | Phone UI |
| FIRE | 21 | Client | Fire/explosion effects |
| RECORDING | 17 | Client | Recording/replay |
| APP | 17 | Client | App integration |
| CLOCK | 16 | Client | Time management |
| EVENT | 13 | Client | Game events |
| WATER | 12 | Client | Water simulation |
| DECORATOR | 12 | Client | Entity decorators |
| SHAPETEST | 11 | Client | Raycasting/collision |
| DLC | 11 | Client | DLC content |
| BRAIN | 11 | Client | AI behavior |
| ZONE | 9 | Client | Map zones |
| ITEMSET | 9 | Client | Item collections |
| LOBBY | 8 | Client | Lobby management |
| SAVEMIGRATION | 7 | Client | Save data migration |
| REPLAY | 6 | Client | Replay system |
| SECURITY | 3 | Client | Security functions |
| LOCALIZATION | 3 | Client | Localization |
Data Types
Parameter Types
| Type | TypeScript | Description |
|---|---|---|
int | number | Integer value |
float | number | Floating-point value |
bool | boolean | Boolean value |
string | string | String value |
hash | number | JOAAT hash (use joaat() helper) |
entity | number | Entity handle |
ped | number | Pedestrian entity handle |
vehicle | number | Vehicle entity handle |
object | number | World object handle |
player | number | Player index |
blip | number | Blip handle |
cam | number | Camera handle |
pickup | number | Pickup handle |
interior | number | Interior handle |
fire_id | number | Fire effect handle |
scr_handle | number | Script handle |
vector3 | [number, number, number] | 3D vector |
table | object | Lua table (object) |
any | unknown | Any type |
function | Function | Callback function |
Return Types
| Type | TypeScript | Description |
|---|---|---|
void | void | No return value |
mut_string | string | Mutable string (output parameter) |
long | number | 64-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
- FiveM Native Reference - Official FiveM documentation
- GTA5 Native Database - Community native database
- alloc8or/gta5-nativedb-data - Source data for natives
Package Information
| Package | Description |
|---|---|
@true_life/swc-plugin-native-inliner | SWC plugin for native call inlining |
@true_life/natives-client | TypeScript definitions for client natives |
@true_life/natives-server | TypeScript definitions for server natives |
@true_life/natives-common | Shared native utilities |