txAdmin icon indicating copy to clipboard operation
txAdmin copied to clipboard

refactor: death handler

Open tomson701 opened this issue 1 year ago • 4 comments

Faster and more optimized method of handling player dead

tomson701 avatar Apr 09 '24 18:04 tomson701

Thanks for the PR

I'm not familiar with those events.
Would that event also trigger when a death is not from a particular damage? Maybe script-caused death or something.
Also, why not CEventDeath instead?

tabarra avatar Apr 09 '24 18:04 tabarra

CEventDeath is not being triggered when you death in my case. It's handle dead from everything as far as i know. Also this event is being used in ESX Legacy and works fine for me.

tomson701 avatar Apr 09 '24 19:04 tomson701

Searching on github for CEventNetworkEntityDamage shows that nobody agrees on what the parameters are.
Here for me on b2944 the parameter that indicates if the player died is data[6], maybe that's not consistent across game versions?

Also, does this even work on RedM?

tabarra avatar May 08 '24 01:05 tabarra

Does CEventPlayerDeath also not work for this situation? It would be nice to be able to use something that wont be triggered a bunch by other stuff.

Its also probably better to use the specific event as the handler instead of using gameEventTriggered

This should work like this:

AddEventHandler("CEventNetworkEntityDamage", function(data)

end)

This got added a few years ago and be less spammy then gameEventTriggered

AvarianKnight avatar May 08 '24 03:05 AvarianKnight