Closed Alexandruuuuu closed 1 year ago
Sorry all i could do to try and help is pasting a comment I typed earlier, because I'm no longer working on GTA V or FiveM mods at all (and haven't for years now). There is also a VERY slight (to no) chance that I will ever return to FiveM Modding at all.
The main tip i could give (by pasting my previous message would be the follow (NOTE: do keep in mind that i DO NOT KNOW IF THIS METHOD STILL WORKS with the recent versions of FiveM though!):
Hey, i also replied to this issue to someone else a while ago. I personally don't do any FiveM stuff anymore, and i'm guessing that A LOT has changed within FiveM/GTAV since i've quit doing mods/scripts.
I however suggest NOT using my script anymore due to possible game engine or FiveM conflicts/issues.
The pasted message bellow (from the previous question) shows a great alternative to get the trains working without any issue (is using the 'native game engine'. It will however NOT support tickets and such (but you could use my code as an example to implement it in your own script(s). Do make sure however that IF you do use my train script (the one you already tried), that you disable the parts which control/spawn the trains).
The pasted message with a more tidy and stable solution: Hey, Sorry due to lots of stuff going on lately in regards to work, personal life and the whole covid situation I haven't had any time to check on things like these earlier, sorry for that.
I personally have stopped a while ago with (most of) my FiveM mods, scripts and servers. However for this on it's unfortunately known that there is an massive issue with either FiveM or GTA V where it can/will go horribly wrong with the trains on several occasions.
This is mainly (my guess though) due to the game engine itself not properly syncing and passing on the 'main host' (aka the closest player) to the spawned train(s).
I have found another solution though which SEEMS to work A LOT better, and uses the 'normal GTA V/GTA:O trains' without any additional scripting required. HOWEVER this would mean that the ticket system for my train system would not work or it would need to be converted to this new method.
I MIGHT see if i can get an FiveM server up and running somewhere in the (near?) future to re-write the script again :) It is quite simple though if you can edit any client script and insert these lines:
Citizen.CreateThread(function() SwitchTrainTrack(0, true) -- Main train track(s) around LS and towards Sandy Shores SwitchTrainTrack(3, true) -- Metro tracks SetTrainTrackSpawnFrequency(0, 120000) -- The Train spawn frequency set for the game engine SetTrainTrackSpawnFrequency(3, 120000) -- The Metro spawn frequency set for the game engine SetRandomTrains(true) -- Telling the game we want to use randomly spawned trains end)
(DISABLE MY ENTIRE SCRIPT THOUGH!)
The trains should work as intended :)
Unfortunately I didn't had these api's/calls available (as in I didn't knew them back then or they where not even discovered/documented yet back then).
Hopefull this is useful for you for now :)
Can you help me ? i watch your issues before but its not the same reason of crash and i will ask you can you help me ? i try your method in client with that function but dont work..