[OneSync] GetVehicleBodyHealth (Server-sided)

Server

Operating system: Linux Ubuntu 18.04
Artifact version: 5687

Incident

Summary: If you set the body health with natives (SetVehicleBodyHealth client or sever-sided) it will sync to the clients, but won’t be syncing with the server’s GetVehicleBodyHealth native, but normal vehicle damage, still syncing the native. If damaging the vehicle purely, it will reduce the damage from the GET native (server-sided)

Example: if the vehicle had 1000HP and you set it to 800HP, it will sync just fine with the clients and will print 800HP if trying the get native (client-sided), but if trying on server-sided, 1000HP will be printed.
After getting somehow (by hitting something) 100 damage to the vehicle: the client will print 700HP (800HP that was set minus 100HP that was caused by the hit), as it should; but on the server-side, it will print 900HP (because the SET native wasn’t synced and the server just received the 100HP damaged caused by the hit)

Expected behavior: If the vehicle’s body health is set, the value should sync to the server-sided native GetVehicleBodyHealth.

Actual behavior: Setting the vehicle’s body health by SetVehicleBodyHealth will sync it to the clients, but stay the same on the server-side.

Steps to reproduce:

  1. Spawn into a vehicle.
  2. Print the vehicle’s body health, both on server and client:
crun print(GetVehicleBodyHealth(GetVehiclePedIsUsing(PlayerPedId())))
// Expected result: 1000.0
run print(GetVehicleBodyHealth(GetVehiclePedIsIn(GetPlayerPed(`your_server_id`))))
// Expected result: 1000.0
  1. Set the vehicle’s body health (it doesn’t matter if by the server-sided natives nor the clients’):
crun SetVehicleBodyHealth(GetVehiclePedIsUsing(PlayerPedId()), 900.0)
  1. Check the vehicle’s body health again just as it was done in step 2:
crun print(GetVehicleBodyHealth(GetVehiclePedIsUsing(PlayerPedId())))
// Expected result: 900.0
run print(GetVehicleBodyHealth(GetVehiclePedIsIn(GetPlayerPed(`your_server_id`))))
// Expected result: 1000.0 (Here you can see the desync)
  1. Damage the vehicle (drive into a wall or something), and check again the values (let’s suppose the damage was 50):
crun print(GetVehicleBodyHealth(GetVehiclePedIsUsing(PlayerPedId())))
// Expected result: 850.0
run print(GetVehicleBodyHealth(GetVehiclePedIsIn(GetPlayerPed(`your_server_id`))))
// Expected result: 950.0 (You can see that it still kinda sync, but only to real
// damage.

Server/Client? Server

If any more information is needed, let me know.

1 Like

To add to this issue:

I recently found out that just sometimes GetVehicleBodyHealth on server side will get some arbitrary values (even negative numbers). I sadly do not have any sort of reproduction for this at the moment as it seems completely random and a rare occurence. Engine health and petrol tank health are completely fine from my observation.

If I can find some reproduction steps, I’ll add them here. But maybe this sheds at least some extra light on this issue.

2 Likes

Which game build are you using ? Did you test with the others ones ?

My issue definitely happens with

  • Gamebuild 2372 and 2545
  • Server version 5562 (latest recommended as of today) and the latest recommended before that (not sure which build number that was)
  • Onesync enabled via set onesync on in the server.cfg

Tested with 2545, 2612, and 1604: Nothing works. seems unrelated.

You tried to do this in server side?

The wrong fields in CVehicleHealthDataNode are being parsed.

unk16 and unk17 should be bodyHealthFine and bodyHealth. The other fields are based on GET_ENTITY_HEALTH and GET_ENTITY_MAX_HEALTH (TU0 debug labels: Has max health and Health).