Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gamestate/server): CREATE_TRAIN(_CARRIAGE) natives #2322

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Ehbw
Copy link
Contributor

@Ehbw Ehbw commented Dec 31, 2023

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 #962

Game builds: 1604-3095

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

Fixes issues

resolves #2197

@Ehbw Ehbw force-pushed the feat/train-server-research branch 4 times, most recently from 0442dc6 to cbe1fd8 Compare January 1, 2024 20:53
Copy link
Contributor

@glitchdetector glitchdetector left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validations do not take into account potential content additions by the server.

@thorium-cfx thorium-cfx added the triage Needs a preliminary assessment to determine the urgency and required action label Feb 12, 2024
@Mycroft-Studios
Copy link

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

@Mycroft-Studios
Copy link

any update on this???

@FjamZoo
Copy link

FjamZoo commented May 6, 2024

Any update on this???

1 similar comment
@CeebDev
Copy link

CeebDev commented Jun 20, 2024

Any update on this???

@Ehbw Ehbw force-pushed the feat/train-server-research branch 3 times, most recently from ede5561 to 2102287 Compare June 21, 2024 14:47
@Ehbw Ehbw force-pushed the feat/train-server-research branch from 2102287 to f6d3a4c Compare June 24, 2024 08:54
@github-actions github-actions bot added invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Jun 24, 2024
@Legacy-TacticalGamingInteractive

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?

@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action and removed invalid Requires changes before it's considered valid and can be (re)triaged labels Jun 25, 2024
@Heisenberg691
Copy link

please merge this, we want trains

@Legacy-TacticalGamingInteractive

please merge this, we want trains

one can only hope heh

@Ehbw Ehbw closed this Aug 9, 2024
@MasterXDev
Copy link

Any update on this???

1 similar comment
@guhblag
Copy link

guhblag commented Oct 17, 2024

Any update on this???

@SSnowly
Copy link

SSnowly commented Oct 17, 2024

MERGE IT, MERGE IT WE WANT TRAINS ON SERVER SIDE GOOOO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Needs a preliminary assessment to determine the urgency and required action
Projects
None yet
Development

Successfully merging this pull request may close these issues.

General train issues