Skip to content

feat(extra-natives/five): GET_TRAIN_TRACK_INDEX #3351

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ static int IsAlarmSetOffset;
static int AlarmTimeLeftOffset;
static int WheelieStateOffset;
static int TrainTrackNodeIndexOffset;
static int TrainTrackIndexOffset;
static int PreviouslyOwnedByPlayerOffset;
static int NeedsToBeHotwiredOffset;
static int IsInteriorLightOnOffset;
Expand Down Expand Up @@ -613,6 +614,7 @@ static HookFunction initFunction([]()
TrainStateOffset = *hook::get_pattern<uint32_t>("89 91 ? ? ? ? 80 3D ? ? ? ? ? 0F 84", 2);
TrainCruiseSpeedOffset = *hook::get_pattern<uint32_t>("C7 87 ? ? ? ? ? ? ? ? E8 ? ? ? ? 4C 89 AF", 2);
TrainSpeedOffset = *hook::get_pattern<uint32_t>("4C 89 AF ? ? ? ? 44 89 AF ? ? ? ? 4C 89 AF ? ? ? ? 49 8B 0E", 3);
TrainTrackIndexOffset = *hook::get_pattern<uint32_t>("8A 8F ? ? ? ? F3 41 0F 58 CB", 2);
}

{
Expand Down Expand Up @@ -1554,6 +1556,8 @@ static HookFunction initFunction([]()

fx::ScriptEngine::RegisterNativeHandler("GET_TRAIN_SPEED", std::bind(readVehicleMemory<float, &TrainSpeedOffset>, _1, "GET_TRAIN_SPEED"));

fx::ScriptEngine::RegisterNativeHandler("GET_TRAIN_TRACK_INDEX", std::bind(readVehicleMemory<uint8_t, &TrainTrackIndexOffset>, _1, "GET_TRAIN_TRACK_INDEX"));

fx::ScriptEngine::RegisterNativeHandler("SET_TRAIN_STATE", makeTrainFunction([](fx::ScriptContext& context, fwEntity* train)
{
int state = context.GetArgument<int>(1);
Expand Down
14 changes: 14 additions & 0 deletions ext/native-decls/GetTrainTrackIndex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
ns: CFX
apiset: client
game: gta5
---
## GET_TRAIN_TRACK_INDEX

```c
int GET_TRAIN_TRACK_INDEX(Vehicle train);
```
## Parameters
* **train**: The train handle
## Return value
The track index the train is currently on.
Loading