Skip to content
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 @@ -1931,6 +1931,48 @@ static void Init()
return train ? train->direction : false;
}));

fx::ScriptEngine::RegisterNativeHandler("GET_TRAIN_CONFIG_INDEX", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto train = entity->syncTree->GetTrainState();

return train ? train->trainConfigIndex : -1;
}));

fx::ScriptEngine::RegisterNativeHandler("GET_TRAIN_DISTANCE_FROM_ENGINE", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto train = entity->syncTree->GetTrainState();

return train ? train->distanceFromEngine : 0.0f;
}));

fx::ScriptEngine::RegisterNativeHandler("IS_MISSION_TRAIN", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto train = entity->syncTree->GetTrainState();

return train ? train->isMissionTrain : false;
}));

fx::ScriptEngine::RegisterNativeHandler("DOES_TRAIN_HAVE_PASSENGER_CARRIAGES", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto train = entity->syncTree->GetTrainState();

return train ? train->hasPassengerCarriages : false;
}));

fx::ScriptEngine::RegisterNativeHandler("IS_TRAIN_RENDERED_DERAILED", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto train = entity->syncTree->GetTrainState();

return train ? train->renderDerailed : false;
}));

fx::ScriptEngine::RegisterNativeHandler("DOES_TRAIN_FORCE_DOORS_OPEN", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto train = entity->syncTree->GetTrainState();

return train ? train->forceDoorsOpen : false;
}));

fx::ScriptEngine::RegisterNativeHandler("GET_PLAYER_FAKE_WANTED_LEVEL", MakePlayerEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity)
{
auto pn = entity->syncTree->GetPlayerWantedAndLOS();
Expand Down
20 changes: 20 additions & 0 deletions ext/native-decls/DoesTrainForceDoorsOpen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
ns: CFX
apiset: server
game: gta5
---
## DOES_TRAIN_FORCE_DOORS_OPEN

```c
bool DOES_TRAIN_FORCE_DOORS_OPEN(Vehicle train);
```

Returns whether this train forces its doors open while a player is inside it.

This reads the flag as it is synchronised for the given train. The client-side `SET_TRAINS_FORCE_DOORS_OPEN` sets this for all trains at once.

## Parameters
* **train**: The train handle

## Return value
Returns true if the train forces its doors open.
18 changes: 18 additions & 0 deletions ext/native-decls/DoesTrainHavePassengerCarriages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
ns: CFX
apiset: server
game: gta5
---
## DOES_TRAIN_HAVE_PASSENGER_CARRIAGES

```c
bool DOES_TRAIN_HAVE_PASSENGER_CARRIAGES(Vehicle train);
```

Returns whether the train has carriages that peds can ride in.

## Parameters
* **train**: The train handle

## Return value
Returns true if the train has passenger carriages.
18 changes: 18 additions & 0 deletions ext/native-decls/GetTrainConfigIndex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
ns: CFX
apiset: server
game: gta5
---
## GET_TRAIN_CONFIG_INDEX

```c
int GET_TRAIN_CONFIG_INDEX(Vehicle train);
```

Gets the index of the train configuration this train was created from, as defined in `traintracks.xml`.

## Parameters
* **train**: The train handle

## Return value
The train's config index, or -1 if the entity is not a train.
18 changes: 18 additions & 0 deletions ext/native-decls/GetTrainDistanceFromEngine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
ns: CFX
apiset: server
game: gta5
---
## GET_TRAIN_DISTANCE_FROM_ENGINE

```c
float GET_TRAIN_DISTANCE_FROM_ENGINE(Vehicle train);
```

Gets how far along the chain this carriage sits, measured from the engine carriage. Returns 0.0 for the engine itself.

## Parameters
* **train**: The train handle

## Return value
The distance from the engine carriage, or 0.0 if the entity is not a train.
18 changes: 18 additions & 0 deletions ext/native-decls/IsMissionTrain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
ns: CFX
apiset: server
game: gta5
---
## IS_MISSION_TRAIN

```c
bool IS_MISSION_TRAIN(Vehicle train);
```

Returns whether the train was created by a script rather than by the ambient train population.

## Parameters
* **train**: The train handle

## Return value
Returns true if the train is a mission train.
18 changes: 18 additions & 0 deletions ext/native-decls/IsTrainRenderedDerailed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
ns: CFX
apiset: server
game: gta5
---
## IS_TRAIN_RENDERED_DERAILED

```c
bool IS_TRAIN_RENDERED_DERAILED(Vehicle train);
```

Returns whether the train is being rendered as derailed, as set by `SET_RENDER_TRAIN_AS_DERAILED`.

## Parameters
* **train**: The train handle

## Return value
Returns true if the train is rendered derailed.
Loading