where did you get this from?
A Russian website (i dont know if i can link It here)
I think you can. or just dm me please.
Hey how do I add more trains? I have a add-on of a train but canāt figure out how to make it work on FiveM
In the client/config.lua, edit/add lines for the blip location coods. You donāt have to be precise as the game finds the track path nearest to you.
When you put train configs into a streamed trains.xml, those configs are added onto the default gameās configs. Streamed trains.xml only adds, it doesnāt replace. So when you figure out the trainID, it begins after the 24 default train configs. So your first train config in your streamed trains.xml will have a trainID of 25.
I have added a commented section of a list of train IDs from all the configs I did. Note that because they add to the trains.xml, remove all the default configs from your streamed version so you arenāt needlessly doubling the number of configs into the 50s.
Also, all of the spawn locations Iāve done, theyāre for the stations also introduced with Train Stations V, so if any use that, go grab the coods listed here for train spawns at the stations
And lastly, youāll notice I have some long trains. From my testing on the server, 60 cars is the absolute limit before they glitch out to other players. So keep your huge sets below 60!
I hope you understand all of this.
-- Marker/Blip Locations/Spawn locations
Config.TrainLocations = {
{ ['x'] = 247.965, ['y'] = -1201.17, ['z'] = 38.92, ['trainID'] = 34, ['trainX'] = 247.9364, ['trainY'] = -1198.597, ['trainZ'] = 37.4482 }, -- 4 Car Metro
{ ['x'] = 210.68, ['y'] = -2425.48, ['z'] = 8.5, ['trainID'] = 32, ['trainX'] = 210.68, ['trainY'] = -2425.48, ['trainZ'] = 8.5 }, -- Elysian Island Station - 8 Car Metro
{ ['x'] = 2602.68, ['y'] = 2932.39, ['z'] = 40.76, ['trainID'] = 32, ['trainX'] = 2602.68, ['trainY'] = 2932.39, ['trainZ'] = 40.76 }, -- Davis Quartz Station - 8 Car Metro
{ ['x'] = 1943.23, ['y'] = 3590.01, ['z'] = 39.78, ['trainID'] = 32, ['trainX'] = 1943.23, ['trainY'] = 3590.01, ['trainZ'] = 39.78 }, -- Sandy Shores Station - 8 Car Metro
{ ['x'] = -316.47, ['y'] = 5964.78, ['z'] = 41.24, ['trainID'] = 32, ['trainX'] = -316.47, ['trainY'] = 5964.78, ['trainZ'] = 41.24 }, -- Paleto Forest Station - 8 Car Metro
{ ['x'] = 2615.93, ['y'] = 1668.34, ['z'] = 27.6, ['trainID'] = 30, ['trainX'] = 2615.93, ['trainY'] = 1668.34, ['trainZ'] = 27.6 }, -- Palmer Taylor Power Station - Tanker Car Train
{ ['x'] = 665.25, ['y'] = -684.32, ['z'] = 25.12, ['trainID'] = 29, ['trainX'] = 665.25, ['trainY'] = -683.32, ['trainZ'] = 25.12 }, -- La Mesa - Grain Car Train
{ ['x'] = 664.54, ['y'] = -696.02, ['z'] = 24.86, ['trainID'] = 28, ['trainX'] = 664.54, ['trainY'] = -696.02, ['trainZ'] = 24.86 }, -- La Mesa - Container Car Train
{ ['x'] = 664.84, ['y'] = -689.02, ['z'] = 25.02, ['trainID'] = 25, ['trainX'] = 664.84, ['trainY'] = -689.02, ['trainZ'] = 25.02 }, -- La Mesa - Flat Car Train
{ ['x'] = 663.89, ['y'] = -699.3, ['z'] = 24.8, ['trainID'] = 31, ['trainX'] = 663.89, ['trainY'] = -699.3, ['trainZ'] = 24.8 }, -- La Mesa - Mixed Car Train
}
--[[ Train IDs ]]
-- 25: 1+20 Car Flat Car Train // freight_config0
-- 26: 2+40 Car Flat Car Train // freight_config1
-- 27: 2+40 Car Container Train // freight_config2
-- 28: 2+57 Car Container Train // freight_config3
-- 29: 2+45 Car Grain Train // freight_config4
-- 30: 2+50 Car Tanker Train // freight_config5
-- 31: 6+53 Car Mixed Train // freight_config6
-- 32: 8 Car Metro // freight_config6
-- 33: 2 Car Metro // metro_config0
-- 34: 4 Car Metro // metro_config1
okay thank you, but what about addons like https://www.gta5-mods.com/vehicles/ls-subway-add-on-beta ? how do i convert them to fivem compatible stuff? i only know how to do cars, not trains
Hello i am having issues getting the train to spawn i hit G in the marker and the marker just disappears and i get this error in the f8 console
how did you manage to stream the train xml?
In a resource just like vehicle data files add this:
data_file 'TRAINCONFIGS_FILE' 'data/trains.xml'
files {
'data/trains.xml',
}
Hopefully that helps.
Again remember that anything you do inside here FiveM treats it as added configs, not replace, so the very first config inside the streamed file will have a trainID of 25.
And @ReallyFiery I canāt yet vouch for addon trains at the moment, but I do indeed intend on having addon trains soon enough such as that LS Subway one so Iāll get back if I have any luck.
Do you have any recommended train.xmls
I just created my own, e.g:
<train_config
name = "freight_config3"
populate_train_dist = "40.0"
announce_stations = "false"
doors_beep = "false"
carriages_hang = "false"
carriages_swing = "false"
link_tracks_with_adjacent_stations = "true"
carriage_gap = "0.1">
<carriage
model_name = "freight"
max_peds_per_carriage = "0"
flip_model_dir = "false"
do_interior_lights = "true"
carriage_vert_offset = "1.65"
repeat_count = "1" />
<carriage
model_name = "freight"
max_peds_per_carriage = "0"
flip_model_dir = "true"
do_interior_lights = "true"
carriage_vert_offset = "1.65"
repeat_count = "1" />
<carriage
model_name = "freightcont2"
max_peds_per_carriage = "0"
flip_model_dir = "false"
do_interior_lights = "true"
carriage_vert_offset = "0.70"
repeat_count = "57" />
</train_config>
From my example above from a few days ago, that being my fourth config in the xml (starting from zero), that turns out to be train ID 28, which is two freight train locos at the front (second one is reversed) pulling a 57 car long train of freight containersā¦ which I will again be clear 60 cars total is the absolute maximum for FiveM streaming.
Remember to have it added to the train config group like so:
<train_config_group name = "freight_group">
<train_config_ref name = "freight_config0" />
<train_config_ref name = "freight_config1" />
<train_config_ref name = "freight_config2" />
<train_config_ref name = "freight_config3" />
</train_config_group>
Thatās really all it comes down to. Just like always watch you donāt muck up any markup, and watch out for any custom models that are bad quality.
Simple. you just add the model in like any other car.
Hey thanks for the tutorial every time I try to spawn my addon metro train, it spawns the Freight train for some reason. do you know a possible solution? btw this is the one I am using LS Subway [Add-On] - GTA5-Mods.com . I am not getting errors with it in the console its just that the right train isnt spawning.
ā Marker/Blip Locations/Spawn locations
Config.TrainLocations = {
{ ['x'] = 103.41, ['y'] = -1687.26, ['z'] = 29.31, ['trainID'] = 24, ['trainX'] = 107.29, ['trainY'] = -1713.03, ['trainZ'] = 29.13 }, -- Trolley
{ ['x'] = 684.43, ['y'] = -701.63, ['z'] = 26.06, ['trainID'] = 23, ['trainX'] = 670.2056, ['trainY'] = -685.7708, ['trainZ'] = 25.15311 }, -- FTrain
{ ['x'] = 247.965, ['y'] = -1201.17, ['z'] = 38.92, ['trainID'] = 33, ['trainX'] = 247.9364, ['trainY'] = -1198.597, ['trainZ'] = 37.4482 }, -- Addon Metro
}
The train.xml is
<train_config
name = "metro_config0"
populate_train_dist = "40.0"
announce_stations = "false"
doors_beep = "false"
carriages_hang = "false"
carriages_swing = "false"
link_tracks_with_adjacent_stations = "true"
carriage_gap = "-0.1">
<carriage
model_name = "lasubway"
max_peds_per_carriage = "6"
flip_model_dir = "false"
do_interior_lights = "true"
carriage_vert_offset = "0.4"
repeat_count = "1" />
<carriage
model_name = "lasubway"
max_peds_per_carriage = "6"
flip_model_dir = "true"
do_interior_lights = "true"
carriage_vert_offset = "0.4"
repeat_count = "1" />
<carriage
model_name = "lasubway"
max_peds_per_carriage = "6"
flip_model_dir = "false"
do_interior_lights = "true"
carriage_vert_offset = "0.4"
repeat_count = "1" />
<carriage
model_name = "lasubway"
max_peds_per_carriage = "6"
flip_model_dir = "true"
do_interior_lights = "true"
carriage_vert_offset = "0.4"
repeat_count = "1" />
</train_config>
<train_config_group name = "metro_group">
<train_config_ref name = "metro_config0" />
</train_config_group>
</train_configs>
Please help if you can.
If thatās your only config youāve added thatās being streamed, the trainID will be 25, as like Iāve said in above posts, there is 24 stock train set configs in the game. Every single config in the streamed trains.xml adds to that. If you kept all the stock configs in, then trainID 33 is only resulting in the same config as trainID 9.
I am assuming this is what youāve done as the script breaks if you try to spawn a non existent trainID.
Also be careful, if you experience a crash when you do try spawning it when itās corrected, then itās correct I can tell you that for sure as Iāve had absolutely no luck with adding that subway train lol.
Still the same problem. The default freight train is spawning for me. btw do I have to add my train model to this?
function LoadTrainModels()
DeleteAllTrains()
Config.ModelsLoaded = false
Log("Loading Train Models.")
RequestModelSync("freight")
RequestModelSync("freightcar")
RequestModelSync("freightgrain")
RequestModelSync("freightcont1")
RequestModelSync("freightcont2")
RequestModelSync("freighttrailer")
RequestModelSync("tankercar")
RequestModelSync("streak1") -- The models I am using now
RequestModelSync("streak2") -- The models I am using now
RequestModelSync("metrotrain")
RequestModelSync("s_m_m_lsmetro_01")
Log("Done Loading Train Models.")
Config.ModelsLoaded = true
end
This is how my train stream file looks like.
I am able to spawn the train using vMenu but not through the train script on the track. I have tried to use id 25 even 26, 27 and 28 but the script still spawns the freight train for some reason. I think I am not able to stream the train.xml file correctly. This is how my train.xml file looks like:
in data file
Please help.
Im having an issue since ive had this script in, when people are walking around there are little red lasers or bits of light coming off of their player, any idea what might be causing this?
Anyway to make it ace permissions based?
Itās working fine to me, it would be good to open and close the tube doors with a key.
I managed to add my own train and spawn it but I cannot move it. I changed ID to regular train and it can move. Any suggestions?
Is there anyway to whitelist the script?