View Single Post
MasterMind420
BANNED
Join Date: Nov 2010
Old 05-10-2018 , 11:01   Re: [CS:S] Hooking Secondary Knife Attack
Reply With Quote #2

Quote:
Originally Posted by Komodo3000 View Post
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.
Use a timer....time exactly when u press attack2. So if it happens 0.3 seconds or whatever after u press the button
MasterMind420 is offline