Raised This Month: $51 Target: $400
 12% 

Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 03-08-2016 , 01:30   Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback
Reply With Quote #1

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!
Phil25 is offline
ddhoward
Veteran Member
Join Date: May 2012
Location: California
Old 03-08-2016 , 01:37   Re: Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback
Reply With Quote #2

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.
__________________

Last edited by ddhoward; 03-08-2016 at 01:38.
ddhoward is offline
Phil25
AlliedModders Donor
Join Date: Feb 2015
Old 03-08-2016 , 02:55   Re: Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback
Reply With Quote #3

Oh I see. Well, damaging friendly players in my rtd rewrite was actually my concern, I'll add the proper checks then.
Phil25 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 03-08-2016 , 11:58   Re: Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback
Reply With Quote #4

Quote:
Originally Posted by ddhoward View Post
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)).

Last edited by WildCard65; 03-08-2016 at 11:58.
WildCard65 is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 03-08-2016 , 13:27   Re: Blocking SDKHooks_TakeDamage in an SDKHook_OnTakeDamage callback
Reply With Quote #5

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.
Mitchell is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode