for custom buttons:
PHP Code:
register_clcmd("+button", "clcmd_plusbutton");
register_clcmd("-button", "clcmd_minusbutton");
public clcmd_plusbutton(id)
{
// player typed "+button"
}
public clcmd_minusbutton(id)
{
// player typed "-button"
}
for already known buttons:
PHP Code:
#include <fakemeta>
public plugin_init()
{
// register plugin and do much more
register_forward(FM_PlayerPreThink, "FM_PlayerPreThink_Pre", 0);
}
public FM_PlayerPreThink(iPlrId)
{
static s_iOldButtons, s_iNewButtons;
s_iOldButtons = pev(iPlrId, pev_oldbuttons);
s_iNewButtons = pev(iPlrId, pev_button);
if( !(s_iOldButtons&IN_JUMP) && s_iNewButtons&IN_JUMP )
{
// player used "+jump"
}
if( s_iOldButtons&IN_JUMP && !(s_iNewButtons&IN_JUMP) )
{
// player used "-jump"
}
}
full buttons list in second case:
PHP Code:
// pev(entity, pev_button) or pev(entity, pev_oldbuttons) values
#define IN_ATTACK (1<<0)
#define IN_JUMP (1<<1)
#define IN_DUCK (1<<2)
#define IN_FORWARD (1<<3)
#define IN_BACK (1<<4)
#define IN_USE (1<<5)
#define IN_CANCEL (1<<6)
#define IN_LEFT (1<<7)
#define IN_RIGHT (1<<8)
#define IN_MOVELEFT (1<<9)
#define IN_MOVERIGHT (1<<10)
#define IN_ATTACK2 (1<<11)
#define IN_RUN (1<<12)
#define IN_RELOAD (1<<13)
#define IN_ALT1 (1<<14)
#define IN_SCORE (1<<15) // Used by client.dll for when scoreboard is held down
__________________