Skip to content

Commit

Permalink
Merge remote-tracking branch 'avarianknight/fix/health-data-node'
Browse files Browse the repository at this point in the history
  • Loading branch information
blattersturm committed May 31, 2023
2 parents 1d8434c + eb52923 commit ef3877c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
Expand Up @@ -374,6 +374,7 @@ struct CVehicleHealthNodeData
bool tyresFine;
int tyreStatus[1 << 4];
int bodyHealth;
int health;
};

struct CVehicleGameStateNodeData
Expand Down
19 changes: 12 additions & 7 deletions code/components/citizen-server-impl/include/state/SyncTrees_Five.h
Expand Up @@ -1011,6 +1011,18 @@ struct CVehicleHealthDataNode
}
}

bool isFine = state.buffer.ReadBit();

if (!isFine)
{
auto health = state.buffer.ReadSigned<int>(19);
data.health = health;
}
else
{
data.health = 1000;
}

bool bodyHealthFine = state.buffer.ReadBit();

if (!bodyHealthFine)
Expand All @@ -1023,13 +1035,6 @@ struct CVehicleHealthDataNode
data.bodyHealth = 1000;
}

bool unk16 = state.buffer.ReadBit();

if (!unk16)
{
auto unk17 = state.buffer.ReadSigned<int>(19);
}

bool unk18 = state.buffer.ReadBit();

if (unk18)
Expand Down
Expand Up @@ -734,6 +734,18 @@ static void Init()
auto pn = entity->syncTree->GetPedHealth();
return pn ? pn->health : 0;
}
case fx::sync::NetObjEntityType::Automobile:
case fx::sync::NetObjEntityType::Bike:
case fx::sync::NetObjEntityType::Boat:
case fx::sync::NetObjEntityType::Heli:
case fx::sync::NetObjEntityType::Plane:
case fx::sync::NetObjEntityType::Submarine:
case fx::sync::NetObjEntityType::Trailer:
case fx::sync::NetObjEntityType::Train:
{
auto pn = entity->syncTree->GetVehicleHealth();
return pn ? pn->health : 0;
}
default:
return 0;
}
Expand Down
7 changes: 5 additions & 2 deletions ext/native-decls/GetEntityHealth.md
Expand Up @@ -8,9 +8,12 @@ apiset: server
int GET_ENTITY_HEALTH(Entity entity);
```
Currently it only works with peds.
Only works for vehicle and peds
## Parameters
* **entity**:
* **entity**: The entity to check the health of
## Return value
If the entity is a vehicle it will return 0-1000
If the entity is a ped it will return 0-200
If the entity is an object it will return 0

0 comments on commit ef3877c

Please sign in to comment.