Raised This Month: $32 Target: $400
 8% 

Solved my hook wont work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ayyyyyyylmao
Junior Member
Join Date: Apr 2018
Old 08-10-2018 , 09:44   my hook wont work
Reply With Quote #1

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

public 
Action:hurtEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
    
SetEventInt(event"dmg_health"0);
    
SetEventInt(event"dmg_armor"0);

But i still receive damage, whats wrong? I allso tried
PHP Code:
public Action:hurtEvent(Handle:event,const String:name[],bool:dontBroadcast)
{
return 
Plugin_Handled;

but no effect
im allso tried use sdkhooks
PHP Code:
public Action:OnTakeDamage(client, &attacker, &inflictor, &Float:damage, &damagetype)
{
damage 0.0;
return 
Plugin_Changed;

still no effect

Last edited by ayyyyyyylmao; 08-10-2018 at 15:22.
ayyyyyyylmao is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 08-10-2018 , 10:43   Re: my hook wont work
Reply With Quote #2

Use return Plugin_Handled for the OnTakeDamage hook.

PHP Code:
if (victim && victim <= MaxClients && IsClientInGame(victim) && IsPlayerAlive(victim)) // you don't have to check for all these. I just personally like doing this.
{
     
damage 0.0;
     return 
Plugin_Handled// returning Plugin_Handled basically zeroes out all damage.
}

return 
Plugin_Continue// you can return Plugin_Changed as well. 
I'm unable to provide a better example at the moment.
__________________
Psyk0tik is offline
ayyyyyyylmao
Junior Member
Join Date: Apr 2018
Old 08-10-2018 , 11:06   Re: my hook wont work
Reply With Quote #3

Quote:
Originally Posted by Crasher_3637 View Post
Use return Plugin_Handled for the OnTakeDamage hook.

PHP Code:
if (victim && victim <= MaxClients && IsClientInGame(victim) && IsPlayerAlive(victim)) // you don't have to check for all these. I just personally like doing this.
{
     
damage 0.0;
     return 
Plugin_Handled// returning Plugin_Handled basically zeroes out all damage.
}

return 
Plugin_Continue// you can return Plugin_Changed as well. 
I'm unable to provide a better example at the moment.
yup, plugin_handled works, but i want make low damage, like 5.0 instead 30.0
ayyyyyyylmao is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 08-10-2018 , 11:10   Re: my hook wont work
Reply With Quote #4

For 0 damage, use Plugin_Handled. For damage modification, use Plugin_Changed.

PHP Code:
if (victim && victim <= MaxClients && IsClientInGame(victim) && IsPlayerAlive(victim))
{
     
damage 5.0;
     return 
Plugin_Changed;
}

return 
Plugin_Continue
__________________
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-10-2018 , 11:29   Re: my hook wont work
Reply With Quote #5

you can't change damage on events
use SDKHook_OnTakeDamage
__________________
8guawong is offline
ayyyyyyylmao
Junior Member
Join Date: Apr 2018
Old 08-10-2018 , 15:17   Re: my hook wont work
Reply With Quote #6

Quote:
Originally Posted by Crasher_3637 View Post
For 0 damage, use Plugin_Handled. For damage modification, use Plugin_Changed.

PHP Code:
if (victim && victim <= MaxClients && IsClientInGame(victim) && IsPlayerAlive(victim))
{
     
damage 5.0;
     return 
Plugin_Changed;
}

return 
Plugin_Continue
thanks
ayyyyyyylmao 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 10:04.


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