PDA

View Full Version : Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback


Phil25
03-08-2016, 01:30
Hey guys!

Here's the situation. A plugin returns Plugin_Handled every time in SDKHook_OnTakeDamage, which successfully blocks all incoming damage, except for SDKHooks_TakeDamage.

How would I block damage from that native if I call it from a different plugin and don't know whether SDKHook_OnTakeDamage will return Plugin_Handled? Is there a way to check it?

Or should I drop SDKHook_TakeDamage altogether and use something different to hurt players?

Thanks for the help!

ddhoward
03-08-2016, 01:37
It can't be done, apparently TakeDamage intentionally bypasses OnTakeDamage in order to avoid infinite loops. This is why the RTD effects Toxic and Timebomb (in pheaxdll's plugin) bypass Friendly Mode; I have no way to stop the damage short of giving the Friendly players full godmode or modifying the RTD plugin.

You'd have to modify the damage-causing plugin to either use something other than TakeDamage, or create a forward in that plugin that other plugins can hook into to tell the first plugin to not deal the damage.

Phil25
03-08-2016, 02:55
Oh I see. Well, damaging friendly players in my rtd rewrite was actually my concern, I'll add the proper checks then.

WildCard65
03-08-2016, 11:58
It can't be done, apparently TakeDamage intentionally bypasses OnTakeDamage in order to avoid infinite loops.

It's done using a feature of SourceHook(the one where you can call the ORIGINAL function instead of calling other hooks(For methods where the original return value can be returned by the hook)).

Mitchell
03-08-2016, 13:27
you could also use a point_hurt to apply damage, instead of Sdkhooks.
However creating and removing an entity isn't really a proper way to do it.