Is there a way to hook secondary knife attack in CS:S?
The 'weapon_fire' event is not fired by secondary attack:
PHP Code:
HookEvent("weapon_fire", EventWeaponFire, EventHookMode_Post);
PHP Code:
public EventWeaponFire(Handle:event,const String:name[],bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
static String:Weapon[32];
GetEventString(event, "weapon", Weapon, sizeof(Weapon));
if(StrEqual(Weapon, "knife"))
{
//Code
}
}
I also tried using
PHP Code:
AddCommandListener(SecondaryAttack, "+attack2")
or
PHP Code:
public Action:OnPlayerRunCmd(client, &buttons)
{
if(buttons & IN_ATTACK2)
{
//Code
}
return Plugin_Continue;
}
but they keep getting called as long as "+attack2" button is pushed and not when the actual attack is performed.
I also need it to work, every time secondary attack is performed and not only when someone is hurt/hit by it, so 'player_hurt' event and 'SDKHook_TraceAttack' is not an option.
__________________