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

You probably have conflicting scripts.
I’m actually working on it to make it stop at station and I don’t have a single problem …

Maybe OneSync again…

I’ve put this to fix the “random car / aicraft spamming spawn and ped driving your car bug” :

set onesyncworkaround763185 1
set onesync_forceMigration true

Pretty sure that onesync_forceMigration is the clue.

Mine is Spanish from Spain

add 2
es Spanish from Spain
mx Spanish from Mexico

Just finished a small rework of the system on my git

I’v finished the train stop at station and fixed the “DeleteMissionTrain” bug when you restart the ressource.
No more 50 trains on the track when you restart the script. It simply destroy these train and re-create these.

It’s still POSSIBLE that the train will not stop at a station. It appear some times when another train leave that station. (Not the same variable but it still strange)

If you could make some test and give some feedback, it could be really cool.

update : when another player join me, the metro / train are mooving again XD

edit : with your last update everythings working !

@Mateo_Chinese: Maked a new topic about the rework since VenomXNL abandonned this project.

1 Like

Just for the record on here to:
I did gave permission to @Nickoos to resume working on this project and ‘expanding’ it, completing it, fixing possible/remaining bugs etc :slight_smile:

Hope he has the time to finish what we started :slight_smile:
Thanks and good luck man :slight_smile:

EDIT:
I just noticed your updated/adapted post, and will add it to my post :slight_smile:

1 Like

can i add more wagons to the train? if so how?

currently not with my script, my script just spawns trains as they are in the game itself.

I do however recommend to also read the main post about known issues you MIGHT encounter when using this (non finished) script, since it still has some bugs in some instances (which depend per server/configuration if they happen/appear or not).

Thank you so much this is awesome! Love how you did not make just for ESX aswell.

1 Like

Anyone figure out how to keep the train from despawning?

We notice that randomly the trains will just no longer be within the game world, but are always there when we do a fresh server reset.

Hey,

I just recently (last week or so) (re-)started working on my own FiveM server (after being away from FiveM for almost two years), and indeed hoped that someone had “fixed” this issue by now or atleast figured out why it happens.

Currently I first have to focus on LOTS of other stuff which I need to get working on my/our server, but if there will be no solution in the future I might/will actually retry fixing it myself someday (however at this point I don’t know when that is due to the MASSIVE list of things which need to be developed first).

Oh nice! Glad to hear your back - and good luck with getting the server up! :smiley:

Im not super great at AI related stuff (like this train for example) but if you need help/advice on other ends, let me know! We have a fairly strong server in terms of scripts and such, and I try to help other owners when I can!

Thanks :slight_smile:

And of course thanks for the offer :slight_smile:

The A.I. and such isn’t much of a problem for me (my daytime job is software (.NET) and hardware developer (MCU’s and PCB’s), however the spawn cycles in GTA seem to be a ‘freaking b*tch’ somehow haha.

It COULD be done by making vehicles/peds/objects etc Mission entity’s but even to make that work you would need to start managing these object on a server level to make 100% sure that stuff won’t vanishes anyway (for example on new players joining/leaving and other ‘de-sync reasons/events’).

MOST of the time the mission entity stuff works fairly well but also with this we haven’t had much luck with the trains.

This however also due to the fact that my ‘condition’ for this script is that i want it to use the 'normal game AI" and NOT a “scripted moving train object”, which only makes this one even harder to manage.

Currently i won’t be getting to this for quite a while though since i’m first working on getting EVERYTHING in the “open world” to work like real life (furniture, pickup items etc) same goes for vending places (both customer side and store owner side) etc etc… Also working on making all the stuff that NPC’s can use accessible/usable by the player itself.

Have completed quite a lot (and will also release stuff which isn’t to far ‘integrated’ into my own framework). So you will definitely see some new releases coming from me rather sooner than later :slight_smile:

If you have some tips on mini games (like golf, tennis, horse betting etc) that are availible as scripts please let me know, haven’t started on those yet, have got the showers FULLY working (including all animations), drinking in appartments, sitting almost on ANY furniture (including static locations), and lots more cool stuff. However the mini games i haven’t started on yet.

One condition though is that is must be as close as possible (OR better) than the original game (just like my Rankbar resembles the real one from GTA:O as much as possible for example).

So if you have any tips for those mini games (or scripts i could use as a starting base to ‘finish’ them) it would be great :slight_smile:

Edit: It seems it didn’t marked it as reply so mentioning you here in the edit @SAVRP

will u update the script for build 2372 with FREIGHTCAR2?

https://forum.cfx.re/uploads/default/original/4X/3/2/7/327e26ff222ae59ebe70e72f07158834656a4831.jpeg

By looks of it at this moment not:

NOTE: Mine is abandoned! an no longer being worked on by me!
You can still use mine if you like, but it has known bugs (as listed bellow), and
isn’t marked as 100% finished either yet!

I have started working on my own server again (after being away from FiveM for about 2 years or so), but the trains are currently the lowest priority though. It MIGHT be that we will look into the issues with the trains and it’s AI + the de-spawning issues it has but that might take quite some while before we get to that point. I’m currently working on A LOT of open world improvements + scripts which can/will be released publicly which give the player(s) MUCH more freedom, realism and control over what they can do in the world/environment which at this moment have MUCH higher priority for me, sorry.

As stated in the main post it’s currently abandoned due to the massive issues the game engine itself causes with the trains despawning, HOWEVER that COULD change at some point because I have recently found some natives and invokes which seem to give me MUCH more control over spawned peds, object, vehicles and more (also on a networked level). HOWEVER, I will NOT publish such findings until I’m absolutely certain that these approaches do not affect the rest of the game in any way, and until I’m 100% certain they do not conflict with other native or ‘standard script calls’.

IF those test (in the long haul) turn out to produce positive results with guaranteed stability, THEN I might reconsider on fixing the train system again after all.

Do keep in mind though that my version is NOT OneSync compatible (nor will I be scripting for OneSync, I’m just using the regular game server).

temp fixes

MetroTrain = CreateMissionTrain(25,40.2,-1201.3,31.0,true)

MetroTrain2 = CreateMissionTrain(25,-618.0,-1476.8,16.2,true)

they moved metro ahead 1 i assume for the new freightcar2

		tempmodel = GetHashKey("freightcar2")
		RequestModel(tempmodel)
		while not HasModelLoaded(tempmodel) do
			RequestModel(tempmodel)
			Citizen.Wait(0)
		end

the main train should be

Train = CreateMissionTrain(math.random(0,24), x,y,z,yesorno)

0-24 for all the diff freight train configs

2 Likes

Hello! This is script is absolutely great! I do have a question however, am I able to make the freight trains longer in terms of size? I’m looking to make them closely related to U.S. size freight trains in terms of how many cargo/shipping crates are connected to the train.

Also, is there a way to limit the amount of freight trains that are on the map. I know you said the default amount is one, but it seems that 3 or 4 spawn in my server. (server contains about 100-200 players at once) I’m thinking this is a matter of just so many people and it no syncing across clients.