Raised This Month: $ Target: $400
 0% 

Detect Reloading Weapons


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-29-2009 , 13:46   Re: Detect Reloading Weapons
Reply With Quote #7

You can try that:

Code:
    #include <amxmodx>     #include <fakemeta>     #include <hamsandwich>     #define CANT_RELOAD_BITSUM  ( 1 << CSW_HEGRENADE | 1 << CSW_SMOKEGRENADE | 1<<CSW_FLASHBANG | 1 << CSW_KNIFE | 1 << CSW_C4 )     #define SHOTGUNS_BITSUM     ( 1 << CSW_XM1014 | 1 << CSW_M3 )     #define MAX_WEAPONS         30   // --| Max number of weapons. ( cs1.6/cz )         const sg_start_reload = 5;    // --| Shotgun start reload sequence.     const m_iId           = 43;   // --| Weapon offset. ( return CSW_* )     const m_fInReload     = 54;   // --| Weapon offset.     new const SoundList[][] =     {         " ",         " "     }     public plugin_init()     {         RegisterHamsReload ();     }         public Event_OnReload ( const i_Ent )     {         if ( UTIL_IsWeaponReloading ( pev ( i_Ent , pev_owner ), i_Ent ) )         {             client_cmd ( 0, "spk %s", SoundList[ random_num( 0, sizeof SoundList - 1 ) ] );         }     }       UTIL_IsWeaponReloading ( const id, const i_Ent )     {         // --| If we're holding a shotgun.         if ( 1 << get_pdata_int ( i_Ent, m_iId, 4 ) & SHOTGUNS_BITSUM )         {             // --| We check its animation instead of m_fInSpecialReload because             // --| Event_OnReload will be called 3 times by ball and it's a pain to             // --| deal with that when we want to play the sound one time.             if ( pev ( id, pev_weaponanim ) == sg_start_reload )  { return 1; }         }         // --| Other weapons.         return get_pdata_int ( i_Ent, m_fInReload, 4 );     }         RegisterHamsReload ()     {         // --| Need to loop through all weapons because Ham sucks. :p         // --| As 'post' is necessary, otherwise the offset will not work.         new s_WeaponName[ 24 ];         for ( new i_Wpid = 1; i_Wpid <= MAX_WEAPONS; i_Wpid++ )         {             // --| Don't register item/weapons which can not reload.             if ( !( ( 1 << i_Wpid ) & CANT_RELOAD_BITSUM ) && get_weaponname ( i_Wpid, s_WeaponName, charsmax ( s_WeaponName ) ) )             {                 RegisterHam ( Ham_Weapon_Reload, s_WeaponName, "Event_OnReload", 1 );             }         }     }

Last edited by Arkshine; 01-29-2009 at 14:00.
Arkshine 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 01:50.


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