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 , 17:22   SDKHooks_TakeDamage BUG?
Reply With Quote #1

Hello i'm having some problems with "SDKHooks_TakeDamage" causing my script to somehow multiply on player_hurt, this have a impact on PrintToChat and the damage being sent sometimes 1-4 times at one shot, including the PrintToChat?

Please help o.o


PHP Code:
public OnPluginStart()
{
    
HookEvent("player_hurt"OnPlayerHurtEventHookMode_Post);
}

public 
Action:OnPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    if( 
victim == attacker // if self damage
    
{
        return 
Plugin_Handled;
    }
    else 
    {
        new 
rand GetRandomInt(1100);
        new 
chance 30;
        if (
rand <= chance)
        {
            
doclaw(attackervictim);
        }
    }
    return 
Plugin_Continue;
}

doclaw(clienttarget)
{
    if (
IsClientInGame(client) && IsClientInGame(target) && IsPlayerAlive(client) && IsPlayerAlive(target) && GetClientTeam(target) != GetClientTeam(client))
    {
        
SDKHooks_TakeDamage(targetclientclient6.0DMG_BULLET, -1NULL_VECTORNULL_VECTOR); //stupid shit causing doubles
        
PrintToChat(attacker"\x04[Claws]\x03 did 6+ dmg");
    }

xines is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-05-2015 , 17:25   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #2

I think the game is causing the event to fire when you call SDKHooks_TakeDamage
WildCard65 is offline
xines
Veteran Member
Join Date: Aug 2013
Location: Denmark
Old 12-05-2015 , 17:30   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #3

So i would need another damage method you think?
xines is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 12-05-2015 , 17:49   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #4

Quote:
Originally Posted by xines View Post
So i would need another damage method you think?
Use the OnTakeDamage SDKHook https://sm.alliedmods.net/new-api/sdkhooks/SDKHookCB SDKHooks_TakeDamage doesn't trigger it
__________________

Last edited by Pelipoika; 12-05-2015 at 17:50.
Pelipoika is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-05-2015 , 17:54   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #5

You could have a boolean value per player that helps stop the loop. Also, you could avoid the two variables for your chance.
Spoiler

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

Okay i tried the "OnTakeDamage", it seemed to remove the doubles with the print and stuff, but it wont seem to damage at all, maybe i did something wrong?

- Thecount, im using this in a shop function where u can buy the claws, so i already have added a way to prevent it from being fired to everyone but thanks, added it into the code so you could see


PHP Code:
public Action:OnPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid"));
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    if( 
victim == attacker // if self damage
    
{
        return 
Plugin_Handled;
    }
    if (
Clawsatk_uses[attacker] == 1)
    {
        if (
GetRandomInt(1,10) <= 3)
        {
            
//doclaw(attacker, victim);
            
SDKHook(attackerSDKHook_OnTakeDamageOnTakeDamage);
            
PrintToChat(attacker"\x04[Claws]\x03 did 6+ dmg");
        }
    }
    return 
Plugin_Continue;
}


public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if (
IsClientInGame(attacker) && IsClientInGame(victim) && IsPlayerAlive(attacker) && IsPlayerAlive(victim) && GetClientTeam(victim) != GetClientTeam(attacker))
    {
        
SDKHooks_TakeDamage(victimattackerattacker6.0DMG_BULLET, -1NULL_VECTORNULL_VECTOR);
    }
}

/*
doclaw(client, target)
{
    if (IsClientInGame(client) && IsClientInGame(target) && IsPlayerAlive(client) && IsPlayerAlive(target) && GetClientTeam(target) != GetClientTeam(client))
    {
        //ServerCommand("wcs_xdealdamage %i %i 6", client, target);
        SDKHooks_TakeDamage(target, client, client, 6.0, DMG_BULLET, -1, NULL_VECTOR, NULL_VECTOR); //stupid shit causing doublezzz
    }
}
*/ 
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 #7

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 #8

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
Dr. Greg House
Professional Troll,
Part-Time Asshole
Join Date: Jun 2010
Old 12-05-2015 , 18:41   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #9

Quote:
Originally Posted by Pelipoika View Post
Use the OnTakeDamage SDKHook https://sm.alliedmods.net/new-api/sdkhooks/SDKHookCB SDKHooks_TakeDamage doesn't trigger it
I'm seeing this the second time now.
The hook not firing is not intended, it's actually a bug. I know that because I have been asking about this a while ago. Please do not advise people to rely on this. I would love to see get this fixed in 2-3 years instead of someone then saying "well it will break a lot of plugins".
__________________
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
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-05-2015 , 18:44   Re: SDKHooks_TakeDamage BUG?
Reply With Quote #10

Quote:
Originally Posted by Dr. Greg House View Post
I'm seeing this the second time now.
The hook not firing is not intended, it's actually a bug. I know that because I have been asking about this a while ago. Please do not advise people to rely on this. I would love to see get this fixed in 2-3 years instead of someone then saying "well it will break a lot of plugins".
I'm pretty sure SDKHook_TakeDamage bypassing the OnTakeDamage hook is intended.
WildCard65 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:43.


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