-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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(extra-natives/five): track switching #3044
base: master
Are you sure you want to change the base?
Conversation
155f6ac
to
b027b49
Compare
Great feature. Using the example, when the train gets to the end track node after a switch, it warps back to the old track to the node index of: I tested this with multiple clients:
|
That's to be expected. When using this in a script you should ideally register the same value across all clients.
The freezing does seem to be unrelated and tied to your VM. Although with the example I provided, the track it switches to is marked as a loop track (although it does not create an actual loop) rather then something like a ping-pong track and therefore will teleport back to node 0 (which is located close to the train tunnel in that area of the map) |
if (newTrack->m_nodeCount < newTrackNode) | ||
{ | ||
fx::scripting::Warningf("natives", "REGISTER_TRACK_SWITCH: Invalid toNode was passed (%i), should be from 0 to %i\n", newTrackNode, newTrack->m_nodeCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (newTrack->m_nodeCount < newTrackNode) | |
{ | |
fx::scripting::Warningf("natives", "REGISTER_TRACK_SWITCH: Invalid toNode was passed (%i), should be from 0 to %i\n", newTrackNode, newTrack->m_nodeCount); | |
if (newTrack->m_nodeCount - 1 < newTrackNode) | |
{ | |
fx::scripting::Warningf("natives", "REGISTER_TRACK_SWITCH: Invalid toNode was passed (%i), should be from 0 to %i\n", newTrackNode, newTrack->m_nodeCount - 1); |
Stops Out Of Bounds stuff
Goal of this PR
Introduce a way to register track switching. Track switching allows for a train to change the track index it is currently navigating along. Suggested by @glitchdetector
How is this PR achieving the goal
introduces
REGISTER_TRACK_SWITCH
andSET_TRACK_SWITCH_ACTIVE
to allow for registration of a train switch and ability to enable/disable the track switchThis PR applies to the following area(s)
FiveM, Natives
Successfully tested on
A test resource showing the functionality plus invalid use cases that are accounted for
track-swapping-example.zip
Game builds: 1604, 2060, 3258, 3407
Platforms: Windows
Checklist
Fixes issues