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

Solved CSGO player_hurt not firing if using SDKHook_OnTakeDamage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-21-2017 , 20:49   CSGO player_hurt not firing if using SDKHook_OnTakeDamage
Reply With Quote #1

i want to change damage to 1
so i use the following code
however, player_hurt event does not fire using this way

then i tried trace attack it fires but only fires when its a headshot..


PHP Code:
#include <sdkhooks>
public OnPluginStart()
{
    for(new 
i=1;i<=MaxClients;i++)
    {
        if(
IsClientInGame(i))
            
OnClientPutInServer(i);
    }
    
HookEvent("player_hurt"Event_PlayerHurtEventHookMode_Post);
}

public 
OnClientPutInServer(client)
{
    
SDKHook(clientSDKHook_OnTakeDamageHook_OnTakeDamage);
}

public 
Action:Hook_OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3], damagecustom)
{
    if (
attacker <= || attacker MaxClients || victim <= || victim MaxClients)
        return 
Plugin_Continue;
        
    
damage 1.0;
    return 
Plugin_Changed;
}

public 
Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontbroadcast)
{
    
PrintToChatAll("player_hurt");

__________________

Last edited by 8guawong; 12-22-2017 at 18:59.
8guawong is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 12-22-2017 , 12:35   Re: CSGO player_hurt not firing if using SDKHook_OnTakeDamage
Reply With Quote #2

Maybe hook OnTakeDamage in Event_PlayerHurt ?
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-22-2017 , 12:54   Re: CSGO player_hurt not firing if using SDKHook_OnTakeDamage
Reply With Quote #3

Quote:
Originally Posted by andi67 View Post
Maybe hook OnTakeDamage in Event_PlayerHurt ?
sorry i do not know the logic behind your statement...
__________________
8guawong is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 12-22-2017 , 16:14   Re: CSGO player_hurt not firing if using SDKHook_OnTakeDamage
Reply With Quote #4

I forgot to post in this, but if you change the damage to something greater than 1.0 does it fire the player_hurt event? Sometimes if the player has armor the calculations are done after TakeDamage, so 1.0 turns into 0.0 and doesn't fire player_hurt event.
Mitchell is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-22-2017 , 18:59   Re: CSGO player_hurt not firing if using SDKHook_OnTakeDamage
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
I forgot to post in this, but if you change the damage to something greater than 1.0 does it fire the player_hurt event? Sometimes if the player has armor the calculations are done after TakeDamage, so 1.0 turns into 0.0 and doesn't fire player_hurt event.
thx Mitchell armor was the reason why it did not fire!
__________________
8guawong 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 17:28.


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