Veteran Member
Join Date: Jan 2010
Location: mom's basement
03-23-2021
, 12:48
Re: Hooking player actions (+reload, +attack2, etc)
#16
brainfart
PHP Code:
public void OnPluginStart () { } public void OnPlayerRunCmdPost ( int client , int buttons , int impulse , const float vel [ 3 ], const float angles [ 3 ], int weapon , int subtype , int cmdnum , int tickcount , int seed , const int mouse [ 2 ]) { static int storebuttons [ MAXPLAYERS + 1 ]; if( storebuttons [ client ] != buttons && IsPlayerAlive ( client )) { storebuttons [ client ] ^= buttons ; //PrintToServer("Player buttons change %b", storebuttons[client]); switch( storebuttons [ client ]) { case IN_RELOAD : { if( buttons & IN_RELOAD ) { // Player push int entity = GetEntPropEnt ( client , Prop_Send , "m_hActiveWeapon" ); if( entity != - 1 ) { char buffer [ 30 ]; GetEntityClassname ( entity , buffer , sizeof ( buffer )); PrintToChat ( client , "%s - You pushed +reload button" , buffer ); } } else { // Player release } } } storebuttons [ client ] = buttons ; } }
Last edited by Bacardi; 03-23-2021 at 12:49 .