I am hooking a knife attack with ham:
PHP Code:
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "BlockKnife")
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "BlockKnife")
This is what I have:
PHP Code:
public BlockKnife(id)
{
if(cached_status && !get_user_aiming (id) == PLAYER)
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
So I want to enable knife attacks only on players, this can be a friend or an enemy.
I tested it like that now but I am getting weird errors:
PHP Code:
public BlockKnife(id)
{
if(cached_status)
if(!is_aiming_at_player(id))
return HAM_SUPERCEDE;
return HAM_IGNORED;
}
stock bool:is_aiming_at_player(index)
{
new target, temp, classname[32];
get_user_aiming(index, target, temp);
pev(target, pev_classname, classname, 31);
if ( equal(classname, "player") )
return true;
return false;
}