fivem
fivem copied to clipboard
feat(gamestate/server): CREATE_TRAIN(_CARRIAGE) natives
Goal of this PR
Allows for server-side creation of functioning trains, to be used in strict and relaxed entity lockdown modes.
How is this PR achieving the goal
By adding the CREATE_TRAIN
and CREATE_TRAIN_CARRIAGE
to allow for the creation of trains and its carriages through server-setters. The following LOAD_TRAIN_CONFIG_FROM_PATH
and LOAD_TRAIN_TRACKS_FROM_PATH
are also added to address the issue of the server lacking knowledge of train configurations and train index's. Currently the information is only used to prevent invalid track ID's and train config indexes which cause unintended client behaviour.
Modifications were required for the client, to have server-setter trains behave as intended when re-entering a the scope of a client or changing ownership. By updating the trains current track node to its relative position and then force blending on ownership change (if the server was the last owner). This has no effect on client created trains or trains actively owned by other players.
While creating this PR I also completed the CTrainGameStateDataNode
based on the research provided by gottfriedleibniz, and some of my own.
Examples of Invalid and Valid uses of these natives can be found here: https://gist.github.com/Ehbw/c40e88f0686275f4a6fe417573babb64
A functioning script snippet can be found here: https://gist.github.com/Ehbw/ef9d2302c4833bab5b23160588ff3a6f
This PR applies to the following area(s)
FiveM, Server, Natives
Successfully tested on
Builds prior to the tuners update (2372) results in all trains being deleted by the owning client when leaving the owner's scope. This behaviour is identical to client created trains on these same builds. This would be resolved with blocking deletion of any server-owned entity as suggested here https://github.com/citizenfx/fivem/issues/962
Game builds: 1604-3095
Platforms: Windows
Checklist
- [x] Code compiles and has been tested successfully.
- [x] Code explains itself well and/or is documented.
- [x] My commit message explains what the changes do and what they are for.
- [x] No extra compilation warnings are added by these changes.
Fixes issues
resolves #2197
imo, it would be nice to get the feature out, and then add support for custom tracks later, a working but limited feature is better than no feature
any update on this???
Any update on this???
Bump, please merge this PR. A lot of work was done in testing this by @Ehbw and this would be an amazing thing to have!
Bump, please merge this PR. A lot of work was done in testing this by @Ehbw and this would be an amazing thing to have!
Yes, would be amazing
Any update on this???
Is this essentially something we can use, if merged ofc, in order to rewrite a script such as https://github.com/LexTheGreat/TrainSportation in order to stop so much desync between our client sided trains etc?
please merge this, we want trains
please merge this, we want trains
one can only hope heh
:eyes: