I couldn’t find a way to get the nearest train so it uses the return of the CreateTrain function, sends that to the server, then the server sends that to everyone else so they can find the nearest train by position. If there is a better way please let me know ;-; I used ray-cast as well as nearest-vehicle.
If you load the resource there are two places the trains spawn
247.9364, -1198.597, 37.4482 – Trolley
670.2056, -685.7708, 25.15311 – Train
Press G to spawn trains, make sure it’s loaded by pressing F8, should say loaded keys.
If you need to restart this resource, press KP8 and it will clear out the trains. If you don’t do this the server will loose track of the trains, and you will have to restart to get rid of it.
F = Enter Exit
W = Accel Forwards
S = Accel Backwards
X = Debug Instant stop 200mph → 0 instantly
F8 = Fivm’s console
Oh, if you get out of the train when next to a spot that it stops at by default (Trolley stops at the train stations) It will start to go around the track by it’s self. There is no driver but it still goes…?
Also, Have you networked your stuff? I cannot seem to be able to network the engine train so that non host can get in :c Mightve got it now, but need someone to test
Yeah, pretty sure you do now i think about it, the host changes the localid for the entity to a network one, then sends that to all the clients which they turn into an entity they can register
Yeah I’m with tea on this one. If you try to get entity id’s from net id’s on the other clients they will be 0.the host will actually have real values.
That’s the problem tea and I have been having with our train scripts
I believe its not a script problem but the engines. The networkidtoent always returns 0… I believe this function is meant to be used directly on gta online and not fivem? I don’t think there is anyway to do networking with trains at the moment…
Well, that’s a problem then for a lot of players other than the host or whoever spawns the train because how can you set other clients in an entity that doesn’t exist to them?
For example if I spawn these trains and save their entity ID and send it to the server.
Then when a new player joins I request that entity table and try to create a blip for the entity it won’t work. It will only work on the player who spawned those trains because the entities exist for them.
The train exists for everyone when you spawn it (If they can see it, it exists), the ent id is just different for each client I believe? And there is no way I can find to get the train after creating it ;-; ortherwise it would be easy, but nearestveh doesn’t return trains