View Single Post
Author Message
Komodo3000
Junior Member
Join Date: Sep 2017
Old 05-10-2018 , 00:11   [CS:S] Hooking Secondary Knife Attack
Reply With Quote #1

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"EventWeaponFireEventHookMode_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"Weaponsizeof(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.
__________________
Komodo3000 is offline