Raised This Month: $ Target: $400
 0% 

SDKHooks_TakeDamage BUG?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-05-2015 , 20:45   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #1

Quote:
Originally Posted by thecount View Post
Wait, did you think my code was trying to make it available to only certain people? Because it doesn't; it fixes the loop. But as others have stated, (if you don't need the original hook) using SDKHooks will be a better and more simple solution.
Yeh sorry i misunderstood what you said, i changed to SDKHooks, so it should not be a problem now.
xines is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-05-2015 , 18:23   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #2

OnTakeDamage is called when the game needs to deal damage to an entity. The event is triggered after the damage is dealt(Which is too late for OnTakeDamage to catch it)
WildCard65 is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 12-05-2015 , 18:29   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #3

PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype

    if (
victim != attacker && Clawsatk_uses[attacker] == 1
    {
        if (
GetRandomInt(110) <= && IsClientInGame(attacker) && IsClientInGame(victim) && IsPlayerAlive(attacker) && IsPlayerAlive(victim) && GetClientTeam(victim) != GetClientTeam(attacker))
        { 
            
//doclaw(attacker, victim); 
            //SDKHook(attacker, SDKHook_OnTakeDamage, OnTakeDamage); //Move this into OnClientConnected or smthn
            
SDKHooks_TakeDamage(victimattackerattacker6.0DMG_BULLET, -1NULL_VECTORNULL_VECTOR); 
            
PrintToChat(attacker"\x04[Claws]\x03 did 6+ dmg"); 
        }
    }
    
    return 
Plugin_Continue

Something like that
__________________
Pelipoika is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-05-2015 , 18:56   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #4

Thanks Pelipoika, it seems to be working now.

I used these for hook and unhook, are they working properly or should i change one of them?

PHP Code:
public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
OnClientDisconnect(client)
{
    
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage);

xines is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 12-05-2015 , 18:59   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #5

Quote:
Originally Posted by xines View Post
Thanks Pelipoika, it seems to be working now.

I used these for hook and unhook, are they working properly or should i change one of them?

PHP Code:
public OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageOnTakeDamage);
}

public 
OnClientDisconnect(client)
{
    
SDKUnhook(clientSDKHook_OnTakeDamageOnTakeDamage);

You don't need to unhook on disconnect, the hook is destroyed when the player entity is deleted
__________________

Last edited by Pelipoika; 12-05-2015 at 18:59.
Pelipoika is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-05-2015 , 19:18   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #6

Quote:
Originally Posted by Pelipoika View Post
You don't need to unhook on disconnect, the hook is destroyed when the player entity is deleted
Ahh okay Thanks alot!
xines is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-05-2015 , 18:56   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #7

I was too before I asked the duck. Feel free to do your own research. Until then (or if you happen to have coded the affected parts), you cannot know. Plus the documentation doesn't mention this behavior or whether or not it is intended. It seems counter-intuitive to assume that the hook won't be called. Personally I'm using my own fork of sdkhooks to fix this (I added an optional param which defaults to the current behavior).
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.
Dr. Greg House is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-05-2015 , 19:19   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #8

Dont forget about SDKHook_OnTakeDamage_Alive as it reports the correct damage that will taken after things like distance and armor are taken into effect.

I don't think it matters in this case but it can be really useful.
__________________
Neuro Toxin is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 12-06-2015 , 10:16   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #9

Quote:
Originally Posted by Neuro Toxin View Post
Dont forget about SDKHook_OnTakeDamage_Alive as it reports the correct damage that will taken after things like distance and armor are taken into effect.

I don't think it matters in this case but it can be really useful.
Do note that it won't always report the true final damage like you will see in player_hurt.

So far I know it doesn't include things like Spy watch resistances in TF2,


...

I think it also didn't include minicrits/crit multipliers (even if the dmgtype has DMG_CRIT).

Probably other miscellaneous stuff such as attributes that add damage vulnerability on things like Powerjack and Cozy Camper.



Also, SDKHooks_TakeDamage won't bypass OnTakeDamage_Alive last I remember. (Okay I forget).
__________________

Last edited by Chdata; 12-06-2015 at 11:16.
Chdata is offline
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-05-2015 , 19:46   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #10

Great, two months ago he was telling me the exact opposite, basing it on the hook not being done correctly.

Can he please clarify this?
__________________
Santa or Satan?

Watch out when you're paying people for private requests! Most stuff already exists and you can hardly assess the quality of what you'll get, and if it's worth the money.

Last edited by Dr. Greg House; 12-05-2015 at 19:46.
Dr. Greg House 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 13:28.


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