-
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(server/gamestate): vehicles natives #3071
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -633,6 +633,27 @@ static void Init() | |
return vn ? vn->isEngineStarting : false; | ||
})); | ||
|
||
fx::ScriptEngine::RegisterNativeHandler("IS_VEHICLE_IN_AIR", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity) | ||
{ | ||
auto vn = entity->syncTree->GetVehicleGameScript(); | ||
|
||
return vn ? vn->isVehicleInAir : false; | ||
})); | ||
|
||
fx::ScriptEngine::RegisterNativeHandler("IS_VEHICLE_DROWNING", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity) | ||
{ | ||
auto vn = entity->syncTree->GetVehicleGameScript(); | ||
|
||
return vn ? vn->isDrowning : false; | ||
})); | ||
|
||
fx::ScriptEngine::RegisterNativeHandler("GET_PED_DEATH_STATE", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: move this to somewhere around line 800 so its near other |
||
{ | ||
auto vn = entity->syncTree->GetPedGameState(); | ||
|
||
return vn ? vn->deathState : 0; | ||
})); | ||
|
||
fx::ScriptEngine::RegisterNativeHandler("GET_VEHICLE_HANDBRAKE", makeEntityFunction([](fx::ScriptContext& context, const fx::sync::SyncEntityPtr& entity) | ||
{ | ||
auto vn = entity->syncTree->GetVehicleGameState(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
ns: CFX | ||
apiset: server | ||
--- | ||
## GET_PED_DEATH_STATE | ||
|
||
```c | ||
int GET_PED_DEATH_STATE(Ped ped); | ||
``` | ||
Retrieves the death state of the ped. | ||
```c | ||
enum eDeathState | ||
{ | ||
DeathState_Alive = 0, // The ped is alive | ||
DeathState_Dying = 1, // The ped is in the process of dying | ||
DeathState_Dead = 2, // The ped is dead | ||
DeathState_Max = 3 // Maximum health? maybe | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: It is just an indicator that the enum has ended. Just a utility - e.g. can be used to iterate through all values of the enum ( Lets either remove or update the comment accordingly. |
||
}; | ||
``` | ||
|
||
## Parameters | ||
* **ped**: The target ped. | ||
|
||
## Return value | ||
Returns the current death state of the ped as a value from the `eDeathState` enumeration. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
ns: CFX | ||
apiset: server | ||
--- | ||
## IS_VEHICLE_DROWNING | ||
|
||
```c | ||
bool IS_VEHICLE_DROWNING(Vehicle vehicle); | ||
``` | ||
|
||
Getter to check if the current vehicle is drowning. | ||
|
||
## Parameters | ||
* **vehicle**: The target vehicle. | ||
|
||
## Return value | ||
Return `true` if the vehicle is drowning (and the vehicle is underwater), `false` otherwise. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
ns: CFX | ||
apiset: server | ||
--- | ||
## IS_VEHICLE_IN_AIR | ||
|
||
```c | ||
bool IS_VEHICLE_IN_AIR(Vehicle vehicle); | ||
``` | ||
|
||
Getter to check if the current vehicle is in the air. | ||
|
||
## Parameters | ||
* **vehicle**: The target vehicle. | ||
|
||
## Return value | ||
Return `true` if the vehicle is in the air, `false` otherwise. |
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.
Seems like this PR is missing the following code in
SyncTrees_Five.h
. It doesn't build without it as it can't instantiateSyncTree
class that is now abstract.