Preventing from getting damaged?Solved
Hi ! I was looking for a way to prevent players getting damaged by cancelling the OnPlayerTakeDamage event vut it seems that the event can't be cancelled and even if I return true/false to the object method it doesn't cancel it :/ So how could I do that ? Thanks in advance !

To cancel the dammage being dealth to the player return 0:

object OnPlayerTakeDamage(PlayerSession session, EntityEffectSourceData source){
   return 0f;
}
5bee9f4b73cc8.png MrBlue

To cancel the dammage being dealth to the player return 0:

object OnPlayerTakeDamage(PlayerSession session, EntityEffectSourceData source){ return 0f;}

Thank you ! Do you know if there is a OnDamage event ? (as it doesn't seems to be one in the doc maybe there is one but not listed)

If not, that's ok, I'll do an other way ^^

ZeTioZ

Thank you ! Do you know if there is a OnDamage event ? (as it doesn't seems to be one in the doc maybe there is one but not listed)

If not, that's ok, I'll do an other way ^^

What do you mean by OnDamage event? There is the OnPlayerTakeDamage hook and the OnEntityTakeDamage hook.

5bee9f4b73cc8.png MrBlue

What do you mean by OnDamage event? There is the OnPlayerTakeDamage hook and the OnEntityTakeDamage hook.

I mean an event while the player Damage something and not get damaged for example if I just want to know where the attacker is, get his position and prevent him from dealing damage if he can't deal damage in his area ^^ but if there is not, I'll just need to check the damage source from the taken damage and make the same checks so it's not too anoying ^^

ZeTioZ

I mean an event while the player Damage something and not get damaged for example if I just want to know where the attacker is, get his position and prevent him from dealing damage if he can't deal damage in his area ^^ but if there is not, I'll just need to check the damage source from the taken damage and make the same checks so it's not too anoying ^^

There is no hook to do such thing, but it's perfectly doable with the 2 hooks i just mentioned. Take a look at my CustomDeathMessages plugin on how to get the attacker PlayerSession: https://umod.org/plugins/custom-death-messages

5bee9f4b73cc8.png MrBlue

There is no hook to do such thing, but it's perfectly doable with the 2 hooks i just mentioned. Take a look at my CustomDeathMessages plugin on how to get the attacker PlayerSession: https://umod.org/plugins/custom-death-messages

Nice thank you it will save me some debugging time ;)

PS: The code was very clear, easy to understand thanks a lot ;)

Locked automatically