[RELEASE] FiveM Freight train (AI) and enterable trams (as passenger) (Suited for Roleplay to)

Your time is appreciated and we wait here for you. Thank you!!
Good luck on all your new projects aswell!

1 Like

It has been updated now.

I have tested it (A BIT!!) and seems like it’s working with the new system now :slight_smile:
Trains do stop, get detected, tickets are validated and invalidated and a wanted level is given after boarding without a ticket (after the player has been warned to leave the metro first) :slight_smile:

You can download it from the github again.

NOTE: REMOVE THE OLD VERSION FIRST! This is a complete ‘re-do’ of the old version

2 Likes

Is it possible to add custom trains to this?

1 Like

That was my question too… since I want to use my “bullet-train” model. I believe it was something about “streaming” the model. [How-to] Stream vehicles/models from server to client

If you would want to replace trains then you should indeed be able to stream “replacement vehicles”. If you would want to add additional trains then it becomes a whole different story though.

However: This script does not do anything (anymore) in regards of controlling, spawning etc the trains. It just enables the default game trains and make use of the models spawned by the game.

If you add additional trains, you will need to adapt the script to recognize the new model name(s), this should not be a problem if you only replace the trains.

I’m however not going to be able to help with this because:

  1. It’s been AGES since I’ve worked seriously on my own FiveM stuff (Aside from this update due to many requests)
  2. I have never ‘messed’ with the trains and the train models (only cars).
  3. There are plenty of topic on how to properly stream vehicles (which is literally a topic on it’s own) :slight_smile:
1 Like

I hope the update is working properly for you now btw? :slight_smile:

1 Like

Yessirrr!! Since you’ve stepped away I’m currently pushing towards getting that damn bullet train of my dreams in my server. that will be a game changer! I did however find another script that closed the door and you couldnt fall out for the subway issue you mentioned… however … you couldn’t get out at all … the script kept saying the locations but then wouldnt stop LMAOOO. but yes! works perfectly, and thank you for your contributions for your time in fivem!!

  • Dan
1 Like

Thanks :slight_smile:

One small note on scripts that actually “mess with”/“control” the trains (which most likely also spawn them in someway): Those scripts (which mine was actually one of tbh) will most likely cause MASSIVE issues with trains despawning, not appearing, our even cause multiple trains spawning (often these issues occur when multiple players are active on the server).

So please be careful when using such scripts… It’s a very technical story to explain why that happens, but it basically comes down to which player is the ‘host’/‘spawner’ of the trains, and if other players can’t “detect” your trains properly it can all go ‘haywire’ quickly.

Mine SHOULD not have that issue anymore now because it’s using the regular game trains. IF something happens now: Blame R* :stuck_out_tongue: haha

1 Like

Thank you a lot for updating the script.

I played around with it a bit and i moved the spawning of the trains to the server-side. Still testing if this actually syncs the trains between players or not.

But because you mentioned the ticket-system. The reason you didn’t find the ticket props on the “upside” stations seems to be, that the whole station itself is a prop.

dt1_21_station

And i tried adding that and it didn’t work :smiley:

So… TLDR.

Thank you for updating, even though you stopped doing so.

1 Like

Hi, i just found this Native thing, it called

SetTrainsForceDoorsOpen

I made a little test for this, just like this:

CreateThread(function ()
    SwitchTrainTrack(0, true)
    SwitchTrainTrack(3, true)
    SetTrainTrackSpawnFrequency(0, 120000)
    SetTrainTrackSpawnFrequency(3, 120000)
    SetRandomTrains(true)
    SetTrainsForceDoorsOpen(false) -- only add this
end)

Now, the train will close doors even a player or players stand in it. :smiley:

3 Likes

Thanks mate! :slight_smile:

Although I’m currently not able to test it, because of a MAJOR lack of time and not having my gameserver hooked up, I did added it to the source code and published it as follows:

 	-- 22-07-2024: Added this native which was found and reported to me by: BigHE4d
	-- on the FixeM CFX.re forum, thanks mate :)
	-- https://forum.cfx.re/t/release-fivem-freight-train-ai-and-enterable-trams-as-passenger-suited-for-roleplay-to/268613/255
	-- NOTE: Due to me not playing FiveM for quite a while anymore, and might be quite a while until
	-- I will (be able) to return, I have NOT tested this native call!
	SetTrainsForceDoorsOpen(false) 

Thanks for your contribution/feedback :slight_smile: :+1:t4:

1 Like

ok. dont know if this is a me thing. but the train dosent move. it just spawns and stands still :frowning:

I have heard about this before, didn’t had this issue myself at all, especially not since my script started using the native train tracks in the game.

HOWEVER, I did heard from others back when I was still active on FiveM, that other scripts which alter traffic, spawn rates, pedestrians etc could interfere with the trains. If possible, I would try to turn of other scripts one by one to see IF the problem is in one of those.

My personal recommendation would be to first start with smaller scripts and then work towards bigger ones. I would also recommend to leave the scripts which don’t seem to be the issue turned off. And once you have found the issue turning them on one by one again. OR if you really have A LOT of scripts on your server, just deactivating/re-activating them in pairs of 2 to 4 to save some time.
which alters spawns to have more (or less) frequent police patrols. Such scripts could for example contain an (incorrect?) call which could in turn ‘mess with the trains’.

Do keep in mind though that the trains (unless it has changed by now) have been a bit problematic/conflicting overall in FiveM (not just with my script). :blush:

Hope this provided you with the possible solution to your problem, or that you at least know where to look now :blush:
Do also note that it might also be an script of which you won’t expect it at all. For example (just saying something random here as example): It could be that you have a police ticket system installed,

1 Like

Any one can help fore add pasenger train fore sandy and paleto?

prop_train_ticket_02
-1700277466
x64i.rpf/recreational/v_coin_op.rpf
prop_train_ticket_02_tu
-455396574
@VenomXNL i believe that is the ticket machines that you looking for

Nope, thanks for your help though😊
The script currently detects it already:

From the script:

local TicketMachines = {'prop_train_ticket_02', 'prop_train_ticket_02_tu', 'v_serv_tu_statio3_'}

However If I remember correctly (haven’t done GTA V/FiveM scripts for yeaaaaars now), there where a couple where there was no other option than using an array with the coordinates of the ticket machines because they where/are integrated into a “map chunk” or “building object” to explain it simple (basically put: Those aren’t stand-alone objects).

Even if/when it will be found (after all these years​:joy:), I won’t have any method of testing it currently. At the moment I’m working on several very different projects and don’t have any of my test servers running or even installed anymore. But if someone “fixes” it, they could always do a pull request on the GitHub and I could look into merging it if it seems correct :blush: