Actually, register_impulse is bad, it catches when cmd.impulse is set in CmdStart and when you block it blocks the whole function and this is a bad point.
Also, there are other conditions in the game in order to take impulse in account, for example if you are in a switch weapon process, impulse is not taken in account, register_impulse doesn't take this feature in account.
Correct method (use more cpu though, but still acceptable) is :
PHP Code:
#include < amxmodx >
#include < fakemeta >
#include < hamsandwich >
public plugin_init()
{
RegisterHam(Ham_Player_ImpulseCommands, "player", "OnCBasePlayer_ImpulseCommands", false);
}
public OnCBasePlayer_ImpulseCommands( id )
{
if( pev(id, pev_impulse) == 100 ) // game gonna take it in account and switch flashlight on or off
{
// if you want to block, set impulse to 0
set_pev(id, pev_impulse, 0);
return HAM_HANDLED;
}
return HAM_IGNORED;
}
__________________