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

SDKHooks_TakeDamage not calling OnTakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xSquared
Junior Member
Join Date: Jan 2019
Old 09-11-2021 , 01:26   SDKHooks_TakeDamage not calling OnTakeDamage
Reply With Quote #1

Hi. I've recently got back into sourcemod plugins relating to TF2, and was wondering how to force TakeDamage to call OnTakeDamage, or call OnTakeDamage. For reference, I am creating custom attributes for the CustomWeapons3 plugin; the attribute I'm working on damages targets around the initial victim, and I would like for it to be able to chain between victims indefinitely.

My current code for the attribute is as follows:
PHP Code:
if (ds_radius[attacker][weapon] != 0)
    {
        for (new 
potvictim 1potvictim <= MaxClientspotvictim++)
        {
            if (!
IsClientInGame(potvictim)) continue;
            if (!
IsPlayerAlive(potvictim)) continue;
            if (
GetClientTeam(potvictim) == GetClientTeam(attacker)) continue;
            
            new 
Float:pos1[3];
            
GetClientAbsOrigin(victimpos1);
            
            new 
Float:pos2[3];
            
GetClientAbsOrigin(potvictimpos2);
            
            if(
GetVectorDistance(pos1pos2) <= ds_radius[attacker][weapon])
            {
                if(
IsValidEntity(inflictor)) SDKHooks_TakeDamage(potvictiminflictorattackerdamage ds_percentspread[attacker][weapon], damagetypeweapondamageForcepos2);
            }
        }
    } 
__________________
xSquared/Silver's Custom Attributes:https://forums.alliedmods.net/showth...02#post2663402
xSquared is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 09-12-2021 , 07:35   Re: SDKHooks_TakeDamage not calling OnTakeDamage
Reply With Quote #2

I remember asking this on SM Discord once and someone said that SDKHooks_TakeDamage don't call SDKHook_OnTakeDamage by design.

I have the same issue with SDKHooks_DropWeapon doesn't trigger SDKHook_WeaponDrop/Post.

Is not kinda a bug.

You can ask on Discord or open an Issue on sourcemod github repo, although you will get a similar reply.

Here is the discord link message in case you wanna check.
__________________

Last edited by Marttt; 09-12-2021 at 07:38.
Marttt is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 09-12-2021 , 07:40   Re: SDKHooks_TakeDamage not calling OnTakeDamage
Reply With Quote #3

...you would not to like to get infinite loop, would you ?
Bacardi is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 09-12-2021 , 07:52   Re: SDKHooks_TakeDamage not calling OnTakeDamage
Reply With Quote #4

SDKHooks_TakeDamage may be called outside SDKHook_OnTakeDamage in some scenarios, which wouldn't cause a loop, in theory.
__________________
Marttt is offline
xSquared
Junior Member
Join Date: Jan 2019
Old 09-17-2021 , 22:18   Re: SDKHooks_TakeDamage not calling OnTakeDamage
Reply With Quote #5

Quote:
Originally Posted by Bacardi View Post
...you would not to like to get infinite loop, would you ?
this is exactly what I want
__________________
xSquared/Silver's Custom Attributes:https://forums.alliedmods.net/showth...02#post2663402
xSquared is offline
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 09-18-2021 , 12:01   Re: SDKHooks_TakeDamage not calling OnTakeDamage
Reply With Quote #6

Quote:
Originally Posted by xSquared View Post
this is exactly what I want
That would just hang/freeze your server. You need to add a delay of some sort.
__________________
GitHub | Discord: @azalty | Steam
azalty is offline
Reply


Thread Tools
Display Modes

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 11:14.


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