mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

onVehicleDamage inconsistent behavior

Open JcynR opened this issue 3 years ago • 1 comments

Describe the bug

addEventHandler('onVehicleDamage', root, function(loss)
    print(loss, source.health)
end)

Vehicle health sometimes returns the old health not the updated health with the loss.

Also, this event behaves different from onPlayerDamage, where if you set the vehicle's health manually onVehicleDamage is triggered but when you set the player's health manually, onPlayerDamage does NOT get triggered. Also see https://github.com/multitheftauto/mtasa-blue/issues/2652 for inconsistent behavior with onPlayerDamage.

Why is everything so broken? Are these new bugs? I've never heard about these issues before. These bugs make it incredibly difficult for me to use these events in my gamemode.

Steps to reproduce

addEventHandler('onVehicleDamage', root, function(loss)
    print(loss, source.health)
end)

Version

Server v1.5.9-release-21244 Client v1.5.9-release-21244

Additional context

No response

Relevant log output

No response

Security Policy

  • [X] I have read and understood the Security Policy and this issue is not security related.

JcynR avatar Jul 04 '22 13:07 JcynR

After some more experimenting...

In the code example, source.health/getElementHealth returns the correct health if I set the health manually via runcode, but if the vehicle is damaged by world damage then it shows the old health.

Very weird behavior!

JcynR avatar Jul 04 '22 13:07 JcynR