multitheftauto/mtasa-blue

[1.7] onPlayerWasted not triggering properly

Closed this issue · 3 comments

Describe the bug

I slapped myself 100 HP with admin panel and noticed I didn't respawn. Turns out killPed works, but setElementHealth(me, 0) doesn't trigger onPlayerWasted:

[CIT]Arran executed command: addEventHandler("onPlayerWasted", root, function() outputChatBox("a") end)
Command results: true [boolean]
[CIT]Arran executed command: killPed(me)
a
Command results: true [boolean]
[CIT]Arran executed command: setElementHealth(me, 0)
Command results: true [boolean]

Could be relevant but I noticed that you can do setElementHealth(me, 100) and it brings you back and returns true, but if you do that after killPed it does nothing and returns false.

Steps to reproduce

Newest 1.7 nightly
srun addEventHandler("onPlayerWasted", root, function() outputChatBox("a") end)
srun setElementHealth(me, 0)

Version

v1.7-untested-25596

Additional context

No response

Relevant log output

Security Policy

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

I think killPed should be changed in the script to setElementHealth instead, so the player respawns normally after being slapped with 100 HP.
Also for the killPed:
Image

I think killPed should be changed in the script to setElementHealth instead, so the player respawns normally after being slapped with 100 HP

That's not the problem though, the problem is that setElementHealth works fine in 1.6 to kill players, some change in 1.7 has broken it.

I had a look to try find what commit caused this new bug, but didn't see one, so I just made a PR that fixes this bug: #4486