Raised This Month: $ Target: $400
 0% 

Why this HamHook doesn't work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danonix
Senior Member
Join Date: Dec 2012
Old 06-24-2014 , 17:17   Why this HamHook doesn't work?
Reply With Quote #1

Hello,

Im trying to do a game for jailbreak, in which nemesis kills terrorist on one shot, but ham for it doesn't work. Can someone tell me what's wrong?
Thanks

Code:
new HamHook: hDmg;
....
public OnRemoveData(day){
  if(day == id_game){
             if(hDmg)
            DisableHamForward(hDmg);
    }
}
....
public OnDayStart(day)
{
    if(day == id_game)
    {
        if(!hDmg)
            hDmg = RegisterHam(Ham_TakeDamage, "player", "fwTakeDamage_JedenCios");
        else
            EnableHamForward(hDmg);
    }
}
....
public fwTakeDamage_JedenCios(id, ent, attacker)
{
    if(is_user_alive(attacker) && get_user_team(id) == 2 && get_user_weapon(attacker) == CSW_KNIFE)
    {
        cs_set_user_armor(id, 0, CS_ARMOR_NONE);
        SetHamParamFloat(4, float(get_user_health(id) + 1));
        return HAM_HANDLED;
    }
    return HAM_IGNORED;
}
danonix is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 06-25-2014 , 06:02   Re: Why this HamHook doesn't work?
Reply With Quote #2

I think ham must be registered in plugin_init, then disable it, when you need - enable. But I might be wrong, but I am doing this in my jailbreak, can't remember why
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-25-2014 , 07:12   Re: Why this HamHook doesn't work?
Reply With Quote #3

Ham hooks can be registered whenever you like.

Looks like the issue is your team check - terrorist team value is 1 not 2.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 06-25-2014 , 13:41   Re: Why this HamHook doesn't work?
Reply With Quote #4

Quote:
Originally Posted by hornet View Post
Ham hooks can be registered whenever you like.
My bad. But is it bad to register it in plugin_init and then disable? I enable it when I need, disable afterwards.
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 06-25-2014 , 14:01   Re: Why this HamHook doesn't work?
Reply With Quote #5

Quote:
Originally Posted by GuskiS View Post
My bad. But is it bad to register it in plugin_init and then disable? I enable it when I need, disable afterwards.
That is perfectly fine, when I need ham hook toggle, I usually do this something like this in plugin_init():
PHP Code:
DisableHamForward((g_hamPreThink RegisterHam(Ham_Player_PreThink"player""hamPlr_PreThink"true))); 
klippy is offline
danonix
Senior Member
Join Date: Dec 2012
Old 06-26-2014 , 16:34   Re: Why this HamHook doesn't work?
Reply With Quote #6

Oh well, this:
Code:
  if(is_user_alive(attacker) && get_user_team(id) == 2 && get_user_weapon(attacker) == CSW_KNIFE)
should be
Code:
  if(is_user_alive(attacker) && get_user_team(attacker) == 2 && get_user_weapon(attacker) == CSW_KNIFE)
Gosh! Thanks for answers. Cheers
danonix 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 21:09.


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