If you want to reset the buttons at any point so that they can be used again, call ClearEntsUsed(). Add as many button classnames as you'd like. I have 'func_button' below and also did 'hostage_entity' as a second example.
PHP Code:
#include <amxmodx>
#include <hamsandwich>
const ENTS_ARRAY_SIZE = 64;
new g_bEntityUsed[ ENTS_ARRAY_SIZE ];
public plugin_init()
{
RegisterHam( Ham_Use , "func_button" , "Ham_ButtonUse" );
RegisterHam( Ham_Use , "hostage_entity" , "Ham_ButtonUse" );
}
public Ham_ButtonUse( iEntity , iUser , idActivator , iUseType , Float:fValue )
{
new szName[ 33 ];
if ( ( iUseType == 2 ) && ( fValue == 1.0 ) && is_user_alive( iUser ) )
{
if ( ( g_bEntityUsed[ iEntity >> 5 ] & (1 << ( iEntity & 31 ) ) ) )
{
return HAM_SUPERCEDE;
}
else
{
get_user_name( iUser , szName , charsmax( szName ) );
client_print( 0 , print_chat , "* Button was used by %s!" , szName );
g_bEntityUsed[ iEntity >> 5 ] |= ( 1 << ( iEntity & 31 ) );
}
}
return HAM_IGNORED;
}
public ClearEntsUsed()
{
for ( new i = 0 ; i < ENTS_ARRAY_SIZE ; i++ )
g_bEntityUsed[ i ] = 0;
}
__________________