Raised This Month: $ Target: $400
 0% 

Need a hook on secondary fire shotgun


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-16-2009 , 22:05   Re: Need a hook on secondary fire shotgun
Reply With Quote #2

Here is one way you could do it. I made this example for usp but you can make it work with any gun by replacing the classname. There is a cvar [bsa_forceprimary] that if enabled [1] will force primary attack if secondary attack is clicked; when disabled the secondary attack will just be blocked.

With this method, when primary attack is forced you will not see the weapon animation when it occurs but it will still occur. Compile\install this code and use secondary attack with usp to see what I mean. Your ammo will go down with each attack but you will not see the weapon fire.

PHP Code:
#include <amxmodx>
#include <fakemeta>

#define m_pActiveItem 373

new g_pForcePrimaryAttack;

public 
plugin_init() 
{
    
register_plugin"Block\Hook Secondary Attack" "1.0" "bugsy" )
    
    
register_forwardFM_CmdStart "fw_FM_CmdStart" );
    
    
g_pForcePrimaryAttack register_cvar"bsa_forceprimary" "1" );
}

public 
fw_FM_CmdStartid Handle 
{
    static 
iButtonsiButtons get_ucHandle UC_Buttons );
    static 
iOldButtonsiOldButtons pevid pev_oldbuttons );
    static 
szWeaponClassName33 ];

    if ( ( 
iButtons IN_ATTACK2 ) && !( iOldButtons IN_ATTACK2 ) )
    {
        
pevget_pdata_cbaseid m_pActiveItem ) , pev_classname szWeaponClassName 32 );
        
        if ( 
equalszWeaponClassName "weapon_usp" ) )
        {
            if ( 
get_pcvar_numg_pForcePrimaryAttack ) )
                
iButtons |= IN_ATTACK;

            
set_ucHandle UC_Buttons iButtons & ~IN_ATTACK2 );

            
//Issue punishment here if desired.
        
}
    }

__________________

Last edited by Bugsy; 06-17-2009 at 00:58.
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:37.


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