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

Custom train tracks: initial server awareness #1715

Merged

Conversation

qaisjp
Copy link
Contributor

@qaisjp qaisjp commented Oct 15, 2020

This fully backwards compatible pull request contains initial support for the train track element and the ability to change between default train tracks. This is the first in a series of pull requests that intends to pick apart the feature/custom-train-tracks branch in #250, so that it can be confidently reviewed and merged without worrying about bugs too much.

You can get default track elements using the below documentation. This documentation is currently only accurate server-side. Client-side it will just return the same number you provide, as clients do not yet have a concept of track elements.

-- OOP: TrainTrack.getDefaultTrack(trackID)
train-track getDefaultTrack(number trackID)

-- trackID: the ID of the default track, one of `0`, `1`, `2`, `3`.

And then set (or get) the track of a train using the following functions:

-- OOP: v:setTrack(t)
bool setTrainTrack(vehicle v, train-track t)

-- OOP: v:getTrack(v)
train-track getTrainTrack(vehicle v)

I have tested sync with one and two players, and track and position syncing seems to work great. The only client changes this PR brings is exposing existing client to the Lua API (a partial revert of 89b5620 / #1713).

The client-side setTrainTrack function is not protected, and can run on server trains. This is consistent with the behaviour of setTrainPosition, setTrainDirection and setTrainSpeed.

Finally, since this code is based on the original feature/custom-train-tracks branch:

Co-authored-by: Jusonex jusonex96@gmail.com
Co-authored-by: Cazomino05 Cazomino05@gmail.com
Co-authored-by: "sebasdevelopment@gmx.com" sebasdevelopment@gmx.com

@qaisjp qaisjp added the enhancement New feature or request label Oct 15, 2020
@qaisjp qaisjp added this to the 1.6 milestone Oct 15, 2020
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

I'm very happy to see this. Nice work, mate.

@qaisjp qaisjp merged commit c610ff3 into multitheftauto:master Oct 16, 2020
@qaisjp qaisjp deleted the feature/ctt/initial-server-awareness branch October 16, 2020 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant