NativeHub
All NativesModelsArtifactsCFXVehicle

Not affiliated with Rockstar Games or Take-Two Interactive. FiveM and Cfx.re are trademarks of their respective owners. cfxnatives.dev is an independent community project.

Maintained by uz-scripts

© 2026 cfxnatives.dev

contact@cfxnatives.dev
VEHICLEClient
Artifact25963
Data sourced from jgscripts artifact-db

CreateMissionTrain

Docs
local retval = CreateMissionTrain(variation, x, y, z, direction)

Description

Train models must be requested before use. See trains.xml (located in Grand Theft Auto V\update\update.rpf\common\data\levels\gta5\trains.xml) for freight and metro variations.

Model names to request can be found by searching model_name in the file.

The Lua usage example provided down below has been provided in such way so users can test each and every train variation.

### Newly added parameters (seen in 2372 build)

NativeDB Added Parameter 6: BOOL isNetwork
NativeDB Added Parameter 7: BOOL netMissionEntity

isNetwork: Whether to create a network object for the train. If false, the train exists only locally.
netMissionEntity: Whether to register the train as pinned to the script host in the R\ network model.

### Train Models:

freight

### Carriage Models:

freightcar
freightcar2 (Added v2372)
freightcont1
freightcont2
freightgrain
metrotrain
tankercar

### Some train variations (default from trains.xml as of build 2372)

17. Very long train and freight variation.
18. Freight train only.
26. Double metro train (with both models flipped opposite to each other). This used to be 25 before the 2802 build, it also used to be 24 before the 2372 build.

Parameters

NameTypeDescription
variationintThe variation id, these can range from 0 to 26 as of build 2802 (previously `0-25` in build 2372 and `0-24` before that).
xfloatSpawn coordinate X component.
yfloatSpawn coordinate Y component.
zfloatSpawn coordinate Z component.
directionBOOLThe direction in which the train will go (true or false)
📍Quick Snippet: Get Coordinates
xyz

Add this command to your client script to retrieve precise locations in-game.

-- Add this to your client.lua. Type /pos in-game to copy coords.
RegisterCommand('pos', function()
    local ped = PlayerPedId()
    local coords = GetEntityCoords(ped)
    local heading = GetEntityHeading(ped)
    local output = string.format("vector4(%.2f, %.2f, %.2f, %.2f)", coords.x, coords.y, coords.z, heading)

    print(output)
    TriggerEvent('chat:addMessage', { args = { '^4[COORD]^0', output } })
end)
🚗Quick Snippet: Get Vehicle
→ Vehicle

Use this to get the current vehicle handle for this native.

-- Get the vehicle the player is currently in
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped, false)

if vehicle ~= 0 then
    print("Vehicle handle: " .. vehicle)
    print("Model: " .. GetEntityModel(vehicle))
else
    print("Player is not in a vehicle")
end
🚗

Vehicle Models

View All
Adder
adder
Alpha
alpha
Blade
blade
Ardent
ardent
Asea
asea
Cogcabrio
cogcabrio
Baller
baller
Blista
blista

Returns

Vehicle

Returns a vehicle handle.

Examples

Official
--[[ 
    This function needs to be invoked prior to calling CreateMissionTrain  or the trains (as well as its carriages) won't spawn.
    Could also result in a game-crash when CreateMissionTrain is called without
    loading the train model needed for the variation before-hand.
]]
function loadTrainModels()
    local trainsAndCarriages = {
        'freight', 'metrotrain', 'freightcont1', 'freightcar', 
        'freightcar2', 'freightcont2', 'tankercar', 'freightgrain'
    }

    for _, vehicleName in ipairs(trainsAndCarriages) do
        local modelHashKey = GetHashKey(vehicleName)
        RequestModel(modelHashKey) -- load the model
        -- wait for the model to load
        while not HasModelLoaded(modelHashKey) do
            Citizen.Wait(500)
        end
    end
end

loadTrainModels()

RegisterCommand("createtrain", function(source, args, rawCommand)
    if #args < 1 then
        TriggerEvent('chat:addMessage', {
            args = { 
                'Error, provide a variation id, you can find those in trains.xml. Variations range from 0 to 26.'
            }
        })
        return
    end
    
    local playerCoords = GetEntityCoords(PlayerPedId())
     -- Now actually create a train using a variation
     -- These coordinates were used for testing: 1438.98, 6405.92, 34.19
    CreateMissionTrain(
        tonumber(args[1]),
        playerCoords.x, playerCoords.y, playerCoords.z,
        true,
        true,
        true
    )
end, false)

Server Artifacts

Data sourced from jgscripts artifact-db
Recommended25963
Known Issues24
25987-25988Node.js sandboxing seems to be causing issues for people - best to avoid for now
21547Multiple (unconfirmed) reports of server-sided natives throwing errors or causing crashes; best to avoid
17462Failed build, ignore
16276Multiple reports of issues loading JS within resources
14583-14716Crash when using the new onEntityBucketChange
14583-14862Timeouts due to latency units being in nanoseconds
13759-13890Mumble (voice) external connections blocked by default
13380-13458Server crashing due to integer encoding (PR#3235)
13079Failed Linux build (works OK if using Windows!)
12933-13045Still crashes (sometimes) when restarting resources due to Node.js 22
12913-12932Causes a crash when restarting Node.js 22
12767os.date() appends null terminator; can break Lua scripts
12651Failed Linux build, ignore
12509Failed build, ignore
12255Unconfirmed, but several reports of server-side issues that don't persist when downgrading; best to avoid
12160-12165Cannot use entity native calls in entityRemoved
12151Crashing if using newest title update (TU)
12092-12135SetPlayerModel may cause SIGSEGV crashes on some clients due to changes in player handling. 12031 and below works fine.
12078-12083Some clients will fail to connect with 'ReadBulk of header failed' error
10930Failed build, ignore
10268-10309sv_experimentalNetGameEventHandler enabled by default; can cause server crashing and reports of issues downgrading after upgrading
10191GetVehicleNumberPlateText server native broken, will cause issues with scripts involving vehicles
10072Crashing when players join
8509State bags not replicated to clients

CommunitySnippets

No snippets yet. Be the first to contribute!