Knowledge from the fieldRedM

_CREATE_MISSION_TRAIN with conductor=true spawns an NPC in the driver seat — delete it before TaskWarpPedIntoVehicle or the player can't drive

learning:36

_CREATE_MISSION_TRAIN with conductor=true spawns an NPC in the driver seat — delete it before TaskWarpPedIntoVehicle or the player can't drive

Context

You spawn a player-driveable train with _CREATE_MISSION_TRAIN (0xC239DBD9A57D2A71). The native docs say "to make the train AI controlled, set conductor to true and set the speed once" — so for an AI-capable engine you pass conductor = true (the 8th BOOL param).

The trap

conductor = true spawns an NPC conductor ped in seat -1 (driver). If you then call TaskWarpPedIntoVehicle(playerPed, train, -1) to let the player drive, it silently fails / the player isn't placed — the seat is already occupied. Symptom: "I spawned the train but I can't get in to drive it," or the player ends up in a passenger seat.

The fix (verified)

Right after spawning, remove the conductor ped, then warp the player:

local train = Citizen.InvokeNative(0xC239DBD9A57D2A71, configHash, x, y, z, dir, false, false, true)
Wait(500)
-- kill the AI before stopping it
Citizen.InvokeNative(0x01021EB2E96B793C, train, 0.0) -- SET_TRAIN_CRUISE_SPEED
Citizen.InvokeNative(0xDFBA6BBFF7CCAFBB, train, 0.0) -- SET_TRAIN_SPEED
local driver = GetPedInVehicleSeat(train, -1)
if driver and driver ~= 0 and driver ~= PlayerPedId() then
  SetEntityAsMissionEntity(driver, true, true)
  DeletePed(driver)
end
TaskWarpPedIntoVehicle(PlayerPedId(), train, -1) -- now the seat is free

Two related gotchas worth knowing

  • The correct RedM speed natives are SET_TRAIN_CRUISE_SPEED 0x01021EB2E96B793C and SET_TRAIN_SPEED 0xDFBA6BBFF7CCAFBB. The GTA V hashes you may find by name (0x16469284DB8C62B5 / 0xAA0BC91BE0B796E3) do not resolve in RedM and silently no-op.
  • _CREATE_MISSION_TRAIN returns a local entity (NetworkGetNetworkIdFromEntity == 0) — other players will not see it without extra networking work.
  • Delete the train via the Lua wrapper DeleteMissionTrain(train), not a raw InvokeNative with an entity pointer.

Linked natives

  • _CREATE_MISSION_TRAIN (0xC239DBD9A57D2A71)
  • SET_TRAIN_CRUISE_SPEED (0x01021EB2E96B793C)
  • SET_TRAIN_SPEED (0xDFBA6BBFF7CCAFBB)

Tags: trains, vehicles, mission-train, conductor, spawn, railroad
Category: natives
Source: scandi-railroad-poc
Created: 2026-05-22T17:57:46.601Z

Back to documentation