AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why this HamHook doesn't work? (https://forums.alliedmods.net/showthread.php?t=242791)

danonix 06-24-2014 17:17

Why this HamHook doesn't work?
 
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;
}


GuskiS 06-25-2014 06:02

Re: Why this HamHook doesn't work?
 
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 :D

hornet 06-25-2014 07:12

Re: Why this HamHook doesn't work?
 
Ham hooks can be registered whenever you like.

Looks like the issue is your team check - terrorist team value is 1 not 2.

GuskiS 06-25-2014 13:41

Re: Why this HamHook doesn't work?
 
Quote:

Originally Posted by hornet (Post 2157063)
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.

klippy 06-25-2014 14:01

Re: Why this HamHook doesn't work?
 
Quote:

Originally Posted by GuskiS (Post 2157234)
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))); 


danonix 06-26-2014 16:34

Re: Why this HamHook doesn't work?
 
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


All times are GMT -4. The time now is 21:09.

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