Trains (The Big Daddy Version)

The resource includes:

  • Automatic freight, passenger, and metro service
  • Player-spawned and player-driven trains
  • Configurable routes, consists, stops, dwell times, acceleration, and braking
  • Passenger boarding positions and one-use tickets
  • Metro station announcements and distance-based train audio
  • Automatic crossing horns, crossing barriers, and ambient traffic control
  • Train, station, and stop blips
  • Configurable station peds and props
  • In-game consist, stop, passenger-position, and station-scenery editors
  • Optional framework payments, target-system support, fare-evasion calls, and ACE permissions

{:links-list}

INSTALLATION

  1. Extract the downloaded product.
  2. Place the complete BigDaddy-Trains folder in your server's resources directory.
  3. Open settings.ini and enter your product key under [licensing].
  4. Review the automatic-train, driving, ticket, and permission settings before starting the resource.
  5. If useMoney=true, configure the framework near the top of server.lua.
  6. If you want fare-evasion calls sent to a CAD, configure server.911.lua.
  7. Add the resource to server.cfg after its required framework resources:
ensure BigDaddy-Trains

DO NOT RENAME THE RESOURCE

The folder must remain named BigDaddy-Trains. Renaming it prevents the resource from loading its configuration and licensed components correctly.

{:is-danger}

REQUIREMENTS AND OPTIONAL INTEGRATIONS

The resource is standalone unless you enable an integration:

Integration Required? Purpose
ox_target or qb-target No Adds target interactions to configured ticket machines
BigDaddy-Gizmo For station-editor Move / rotate Provides visual placement of station peds and props; numeric position and rotation editing remains available without it
NAT, QB, ESX, ND, or BigDaddy-Money No Charges players when useMoney=true; the QB bridge requires qb-core exports
BigDaddy-LocalsCall911, Sonoran CAD, Imperial CAD, SnailyCAD, or custom code No Receives metro fare-evasion calls

When neither supported target resource is running, ticket machines still work through the built-in proximity prompt.

QUICK START

A typical automatic-service setup looks like this:

[licensing]
key1=YOUR_PRODUCT_KEY

[settings]
UseAcePermissions=false
AcePermission=

AutoSpawnFreight=true
FreightSpawnIntervalMinutes=15
MaxFreightTrains=1

AutoSpawnPassenger=true
PassengerSpawnIntervalMinutes=20
MaxPassengerTrains=1

AutoSpawnMetro=true
MetroSpawnIntervalMinutes=5
MaxMetroTrains=3

MinimumTrainGapMeters=100
TrainFollowingBraking=0.60

allowDriving=true
useMPH=true
showTrainBlips=true

ticketPrice=25
passengerTicketPrice=75
useMoney=false

MetroTicketMachineModels=prop_train_ticket_02,whit_bd_ticketbooth_01
PassengerTicketMachineModels=whit_bd_ticketbooth_02

allowDerail=true
autoDerail=true
riskChance=20
debug=false

Automatic service starts when the first player joins. Each enabled train type spawns up to its configured maximum, using its interval for additional trains. When the server becomes empty, automatic trains are removed and their schedules reset.

SETTINGS.INI REFERENCE

The supplied settings.ini enables automatic service, driving, and derailment, sets MaxFreightTrains=1 and MetroSpawnIntervalMinutes=5, and includes passenger ticket-machine models. Review that file when installing.

Licensing and permissions

Setting Default Description
key1 None Product key from your Big Daddy Scripts account. Place it under [licensing].
UseAcePermissions false When enabled, restricts train commands and all four editors to the configured ACE permission.
AcePermission command ACE object checked when permissions are enabled. Use a specific value such as bigdaddy.trains.

Automatic trains

Setting Default Description
AutoSpawnFreight false Enables automatic freight trains.
FreightSpawnIntervalMinutes 15 Minutes between freight spawns. Valid range: 0.1 to 1440.
MaxFreightTrains 2 Maximum automatic freight trains. Valid range: 0 to 32.
AutoSpawnPassenger false Enables automatic passenger trains.
PassengerSpawnIntervalMinutes 20 Minutes between passenger spawns. Valid range: 0.1 to 1440.
MaxPassengerTrains 1 Maximum automatic passenger trains. Valid range: 0 to 32.
AutoSpawnMetro false Enables automatic metro trains.
MetroSpawnIntervalMinutes 7 Minutes between metro spawns. Valid range: 0.1 to 1440.
MaxMetroTrains 3 Maximum automatic metro trains. Valid range: 0 to 32.
MinimumTrainGapMeters 100 Reserved distance between trains sharing a route. Valid range: 20 to 1000 meters.
TrainFollowingBraking 0.60 Braking rate used to maintain separation. Valid range: 0.05 to 5.0 m/s².

The first train of every enabled type starts when a player is online. Additional trains are placed in the largest available gap on their route. When several consists exist for one type, the scheduler varies its selection and avoids immediately repeating the previous consist when possible.

Driving, tickets, blips, and derailment

Setting Default Description
allowDriving false Allows players to use /trainspawn, enter the driver's position, and operate their train. Automatic and player-driven trains may run simultaneously.
useMPH true Displays current and target driving speeds in MPH. Set to false for KM/H.
showTrainBlips true Enables nearby train and stop blips.
ticketPrice 25 Price of a one-use metro ticket.
passengerTicketPrice 75 Price of a one-use passenger ticket.
useMoney false When false, valid ticket purchases are issued without charging money. When true, server.lua must confirm payment first.
MetroTicketMachineModels prop_train_ticket_02,... Comma-separated object models that sell metro tickets. The supplied file overrides this list.
PassengerTicketMachineModels Empty Comma-separated object models that sell passenger tickets.
allowDerail false Enables /trainderail and the synchronized custom derailment system.
autoDerail false Allows qualifying vehicle impacts to trigger a derailment.
riskChance 0 Percentage chance that an eligible automatic derailment occurs. Valid range: 0 to 100.
debug false Enables additional diagnostic output. Leave disabled unless troubleshooting.

DesyncKey is an internal value and should not be changed.

Locale settings

The current resource reads user-facing text overrides from [locales] and uses built-in English text when a key is missing. Common ticket overrides in the supplied settings include:

Setting Purpose
thankYouPurchase Successful metro-ticket purchase message
thankYouPassengerPurchase Successful passenger-ticket purchase message
noFunds Message shown when a payment cannot be completed

The supplied [locales] section also includes transit branding, station notices, ticket failures, fare enforcement, boarding, driving, derailment, diagnostic, and editor messages. Preserve placeholders such as {ticketType}, {consistId}, and {routeId} when translating. Branding and fare-call keys include transitBrand, transitCallSource, and fareEvasionCall. Some HUD labels and editor control hints remain built into the client.

ACE PERMISSIONS

When UseAcePermissions=true, the server checks AcePermission before allowing train commands or editor actions. The permission is checked again when an editor saves changes.

Example settings.ini:

UseAcePermissions=true
AcePermission=bigdaddy.trains

Example server.cfg:

add_ace group.admin bigdaddy.trains allow
add_principal identifier.license:YOUR_LICENSE_IDENTIFIER group.admin

Console-issued diagnostic commands remain available to the server console. Player commands follow the configured ACE rule.

CUSTOM AUDIO

Some custom train audio goes through NUI sound players which is a different volume setting than the game comes through. It would be the same as your web browser uses. If some audio is way too loud or too soft then check your web browser volume.

AUTOMATIC SERVICE

Freight and passenger trains use the statewide route supplied as freight-main. Metro trains use the city circuit supplied as metro-main. The server controls the complete logical fleet and keeps all clients synchronized, including players who join after a train has already started.

Trains automatically:

  • Accelerate, brake, dwell, and depart according to the stop configuration
  • Maintain separation from another train ahead on the same circuit
  • Sound station and railroad-crossing horn patterns
  • Stop ambient road traffic and operate supported crossing barriers
  • Play type-specific idle, start, running, stopping, horn, and derailment audio
  • Show nearby train and station blips when enabled
  • Damage and push peds, vehicles, and suitable world objects that they strike

Automatic service and player driving are compatible. Trains do not physically collide with other rendered train copies, but the server's headway system slows or stops a following train before it reaches the train ahead.

After completing a full circuit, an automatic freight train can be replaced at its original spawn position with another configured freight consist. Replacement is skipped when a player is within 400 meters of that position and reconsidered after another circuit. Passenger and metro service do not use this freight replacement rule.

PLAYER COMMANDS

Command Description
/trainspawn Lists the configured consist IDs.
/trainspawn <consist-id> Spawns that consist on its normal route at the track point nearest the player.
/trainspawn <consist-id> <route-id> Spawns the consist on an explicitly selected route.
/trainremove Removes the train owned by the player.
/trainderail Derails the train currently being driven. Available only when allowDerail=true.

Each player may own one train at a time. A spawn is rejected if another train is too close to the nearest route position. Player-owned trains are removed when their owner disconnects or when the server becomes empty.

The supplied consist IDs may be changed in data/train_consists.xml. Run /trainspawn without arguments to see the IDs currently loaded by your installation.

DRIVING CONTROLS

The locomotive must be stopped before the owner can enter or exit its driving position.

Control Action
F near the locomotive Enter the driver's position
F while stopped Exit the driver's position
Up Arrow Increase target speed by 1 m/s
Down Arrow Decrease target speed by 1 m/s; negative speeds reverse the train
E Hold to sound the train horn
B Hold the service brake; release it to hold the newly reached speed
Spacebar Apply the latched emergency brake
Enter Ring the bell (freight trains)

Target speed is limited to -35 through 35 m/s. The service brake produces a normal stop without sparks or brake squeal. The emergency brake adds brake effects and remains active until the train reaches zero.

The driving HUD shows current speed, target speed, and service or brake status. useMPH changes its displayed units; arrow-key adjustments still change the target by 1 m/s.

PASSENGERS, STOPS, AND TICKETS

Passengers can board only while a train is in its stopped/dwelling state. Automatic trains enter this state at configured stops; player-driven trains can enter it when stopped with a zero target speed, including away from a configured station. Walk to a configured passenger position and use F BOARD TRAIN. While the train is stopped again, use F EXIT TRAIN to leave. The server reserves passenger positions so two players cannot occupy the same spot.

Passenger positions are model-specific. If a car has no positions in data/train_passenger_config.xml, it cannot be used for boarding until positions are added with the passenger editor.

Ticket machines support two interaction methods:

  • ox_target or qb-target, when either is running
  • The built-in E proximity interaction when no supported target system is running

A player may hold one valid ticket of each type. A metro ticket is consumed after successful metro boarding. Metro passengers without a valid metro ticket are still allowed to board, but one fare-evasion event is sent through server.911.lua. Passenger tickets can be sold, but are currently neither checked nor consumed during passenger-train boarding. Ticket state is cleared on disconnect or resource restart.

The tickets are NOT integrated with inventory systems, but are held locally to the script for each player. The ticket will not persist after a server restart and are non-transferrable between players.

Money setup

Leave money framework set to custom in the server.lua to issue tickets without charging an account. To charge players:

  1. Open server.lua.
  2. Set framework to nat, qb, esx, nd, bigdaddy, or custom.
  3. Configure any optional society-account values.
  4. For custom, replace the placeholder purchase branch with your server-authoritative balance check and debit. Return success only after money has actually been removed.

The ticket manager validates the ticket type and price before requesting payment. A ticket is issued only after server.lua reports a successful debit.

Fare-evasion calls

Configure cad in server.911.lua as none, sonoran, imperial, snaily, or your custom provider. With none, BigDaddy-LocalsCall911 can receive the existing event when installed. Provider-specific API details must also be completed in that file.

CONFIGURATION FILES

This version or Trains does not use train indexes. Routes, consists, stops, and boarding use four XML files; station scenery uses a separate JSON file:

File Purpose
data/train_routes.xml Closed route geometry, route IDs, default train types, and route speeds
data/train_consists.xml Named freight, passenger, and metro consists plus car placement and liveries
data/train_stops.xml Route nodes used as stops plus dwell, acceleration, braking, names, and announcement keys
data/train_passenger_config.xml Boarding distance, exit offset, passenger positions, and animation presets
data/trainstations.json Ambient station peds and props, including their models, placement, and actions

Manual XML edits require a resource restart. Saves made through the consist, stop, and passenger editors refresh the live configuration immediately. Active trains using an edited consist receive a new definition and rebuild from the saved spacing, height, and livery values.

BACK UP XML FILES BEFORE EDITING

Invalid XML, an unknown route or model, duplicate defaults, and out-of-range nodes can prevent the train system from initializing. Keep each XML element's opening tag and attributes on a single line, with double-quoted attribute values. This includes <TrainStops> and each <Vehicle> or <Stop> entry because the loader reads one line at a time.

{:is-warning}

Routes

Each <Route> in train_routes.xml has a stable ID, default train type, speed, and ordered collection of 3D rail nodes. Routes must be closed circuits. The supplied configuration provides freight-main and metro-main.

Large route node lists are read locally by the server and every client rather than sent across network events. All players must therefore run the same resource files.

Consists

Every train type must have exactly one default consist. A vehicle entry supports:

Attribute Description
model Vehicle model name
livery Requested livery index
offset Gap in meters behind the preceding car; use 0 for the locomotive
zOffset Per-car vertical adjustment after automatic rail-height placement
headingOffset Per-car rotation relative to the route direction
repeat Optional number of repeated copies of that vehicle entry

railHeightOffset on the consist sets the base wheel-to-rail placement correction. Use the in-game consist editor for spacing, height, and livery adjustments whenever possible.

LIMITS

As of now there is a 64 car limit to trains. This is for performance purposes only. If the train's movement is choppy then reduce the number of cars or the number of trains spawned as it might be overpowering your server. More cars and more trains = more power needed to control them

{:is-info}

Stops

A stop matches only the configured route and trainType. Global defaults belong on the <TrainStops> element:

<TrainStops version="1" defaultDwellSeconds="20.0" defaultDwellSecondsMetro="20.0" defaultDwellSecondsFreight="120.0" defaultDwellSecondsPassenger="45.0" defaultAcceleration="0.60" defaultBraking="0.60">

An individual <Stop> may override dwellSeconds, acceleration, or braking. Metro stops may also provide a display name and an announcement key. For custom announcements, add a lowercase OGG file with the matching key to html/sounds and ensure it remains covered by the manifest's sound-file entry.

Passenger positions

Passenger spots are local to a car model:

  • x, y, and z position the passenger inside the model
  • heading rotates the passenger relative to the car
  • type is standing or sitting
  • animDict and anim must either both be valid or both be blank

Use the passenger-position editor instead of hand-measuring these values.

Station scenery

data/trainstations.json is an array of station ped and prop definitions, separate from the operational stops in train_stops.xml. Preserve the supplied entry structure when editing model hashes, positions, rotations, and ped actions. Supported actions include Drink Coffee, Smoke, and Walk; Walk, Any - Walk, and Any - Warp make peds wander around their saved position.

Each client creates its own non-networked station entities after licensing succeeds and removes them on desync or resource shutdown. Use /trainstationedit to manage these items in game; successful saves update connected players without a resource restart. Restart the resource after manually editing the file. Missing or invalid station JSON disables station scenery and produces an F8 message.

IN-GAME EDITORS

All editor commands use the same ACE permission as the train commands when permissions are enabled. Editors write directly to the resource's XML or JSON files, so the server process must have permission to write inside the resource directory.

Consist editor

Use:

/trainconsistedit <consist-id> [route-id]

The selected consist is placed on the nearest point of the appropriate route. Walk near a car to select it.

Control Action
Left/Right Arrow Decrease/increase the selected car's coupling gap by 0.05 m
Up/Down Arrow Raise/lower its zOffset by 0.05 m
Page Up/Page Down Cycle available liveries
Enter Validate and save the complete consist
Escape Close without saving

Models and headings cannot be changed through this editor. A consist that used repeat is expanded into individual vehicle lines when saved so every edited car retains its own values.

Stop editor

Use:

/trainstopedit <freight|metro|passenger>

The editor selects the route nearest the player and displays nearby route nodes. The closest node is orange; existing stops for the selected train type are green.

Control Action
Enter Add the closest node as a stop
Delete Remove the selected train type's stop from that node
Escape Close the editor

The editor remains open after a successful change so several stops can be configured in one session. Newly added stops receive stable generated IDs.

Passenger-position editor

Use:

/trainpassengeredit <train-car-model>

The model must already be used by a configured consist. Walk inside the preview car and press Enter to add a standing position. Move within three meters of an existing marker to select it.

Control Action
Enter Add a position at the player's current location
Left/Right Arrow Change local X by 0.05 m
Up/Down Arrow Change local Y by 0.05 m
Page Up/Page Down Change local Z by 0.05 m
Shift + Left/Right Arrow Rotate heading by 2.5 degrees
Tab Switch between standing and sitting
Q / E Cycle compatible animation presets
Spacebar Preview or stop previewing the selected position and animation
C Toggle the aisle camera
Mouse Wheel Move the aisle camera forward or backward
X Reverse the aisle camera direction
Delete Remove the selected position
F5 Save all positions for the model
Escape Cancel and close

Station editor

Use:

/trainstationedit

This editor manages the peds and props saved in data/trainstations.json. Use /trainstopedit to change where trains stop; the station editor manages scenery. It is not a required function to the script but is just a way to add ambient peds and props to the areas where trains stop. It's not a super polished editor but just meant to be an easier way to visually add stuff.

  1. Stand near the station items you want to manage and open /trainstationedit.
  2. Choose an item from Nearby Items and click Edit, or use Add item to create a ped or prop. Duplicate creates a new copy near your player without replacing the original.
  3. Select Ped or Prop, enter its model name or numeric hash, and adjust its position and rotation. Rotation Z controls heading.
  4. For peds, select a scenario such as Drink Coffee, Smoke, or Walk, or choose Custom scenario and enter a WORLD_ scenario name. Allow movement / physics controls the item's Dynamic option; props also have a Door object option.
  5. Click Preview changes to inspect the draft. For visual placement, start BigDaddy-Gizmo and click Move / rotate. Accept placement in the Gizmo, then click Save in the station editor to persist it.

The nearby list includes station items within 60 metres. Alternatively, click Select in world, look at an item within 40 metres, and press E when its selection marker appears. Press F6 (bindable) to reopen the tools while the editor session is active.

Cancel discards the current draft. Escape or the close button exits the editor and discards unsaved changes. Accepting Gizmo placement or previewing an item does not save it. To remove a saved item, select Edit, click Delete, and then Confirm delete; the deletion applies to everyone.

Successful saves and deletions update connected players immediately and persist through restarts. If another edit changes the station data while you have a draft open, cancel and reopen the editor before saving again. Install the updated client and server DLLs, manifest, html/index.html, html/station-editor.js, and html/station-editor.css together when upgrading.

IMPORTANT BEHAVIOR

Client-local trains

The physical train cars are local, non-networked vehicles synchronized from server-owned logical state. This is intentional. We do not create them with CreateMissionTrain, attempt to network the client copies. Do not add the old trains.xml/train-index system. It is not compatible with this system.

Late joiners receive the active fleet at its current route distance. Distance-based processing reduces the rendering cost of faraway trains without pausing the server simulation.

Visible doors

The included vehicle models expose train-door metadata, but their doors do not respond to normal vehicle-door natives when each car is created as a local vehicle. Stops, dwell state, boarding, exit placement, prompts, and tickets still operate. Visible animated doors require vehicle assets authored for a non-mission-train control path which I don't believe actually exist since no one really does it this way. So TLDR, the doors do not open. Thus the warping into the train when you enter.

Crossing behavior

Automatic barrier control supports the supplied GTA crossing-arm models and compatible custom-map placements. The traffic stop affects ambient AI vehicles only; it does not take control away from player-driven vehicles.

Derailments

Derailments remain synchronized even though train cars are local. The server records the derailment state and every client reconstructs the same articulated slide, effects, and cleanup. Cars that lose rail or ground support can separate and fall under local physics.

TROUBLESHOOTING

The resource does not start

  • Confirm the folder is named exactly BigDaddy-Trains.
  • Confirm the product key is present under [licensing].
  • Check the server console for licensing, XML, missing-file, or configuration errors.
  • Make sure the complete release was installed, not only updated DLL files.
  • Confirm settings.ini, all four XML files, data/trainstations.json, NUI assets, and streamed files are declared and present.

Automatic trains do not appear

  • Confirm the appropriate AutoSpawn... setting is true and its maximum is greater than zero.
  • At least one player must be connected.
  • Check /traintest status, /traintest routes, and /traintest consists.
  • Check the server console for invalid XML, a missing default consist, or an unknown route.

A player cannot spawn or edit trains

  • Confirm allowDriving=true for player-owned trains.
  • If ACE permissions are enabled, verify the player has the exact configured AcePermission.
  • A player must remove an existing owned train before spawning another.
  • Move closer to the intended route and away from another active train.

A ticket is not issued

  • With useMoney=true, verify the selected framework in server.lua is running and its payment branch can debit the player.
  • A custom framework returns failure until its placeholder code is implemented.
  • Confirm the machine model appears in the correct comma-separated setting.
  • Check both the server console and the player's F8 console for payment or interaction errors.

Players cannot board

  • The train must be in its stopped/dwelling state. Automatic trains need a stop configured for their route and type; player-driven trains must be stopped with a zero target speed.
  • The car model must have passenger spots in data/train_passenger_config.xml.
  • The player must be within the configured boardingDistance of an available spot.
  • Use /trainpassengeredit <model> to inspect or add positions.

Blips or custom audio are missing

  • Confirm showTrainBlips=true for blips.
  • Install the complete stream, audiodirectory, html, and data folders.
  • Clear stale client cache after replacing streamed texture or audio assets.
  • Custom station announcement keys must match lowercase OGG filenames in html/sounds.

When requesting support, include the relevant server-console output, the player's F8 log, your non-secret settings, and the exact command or train type involved.