No thoroughly tested
PHP Code:
#include <amxmodx>
#include <engine>
new const Version[] = "0.1";
new g_Entity, g_iNumSmokes[ MAX_PLAYERS + 1 ] , g_Smoking , g_pNumSmokes , bool:g_bThinking;
public plugin_init()
{
register_plugin( "Smoke Plugin" , Version , "bugsy" );
g_pNumSmokes = register_cvar( "sp_numsmokes" , "120" );
register_clcmd( "say .smoke" , "SaySmoke" );
g_Entity = create_entity( "info_target" );
entity_set_string( g_Entity , EV_SZ_classname , "smoke_entity" );
register_think( "smoke_entity" , "EntityThink" );
}
public client_disconnect( id )
{
g_Smoking &= ~( 1 << ( id & 31 ) );
g_iNumSmokes[ id ] = 0;
}
public SaySmoke( id )
{
if ( !is_user_admin( id ) )
return PLUGIN_HANDLED;
if ( !( g_Smoking & ( 1 << ( id & 31 ) ) ) )
{
g_iNumSmokes[ id ] = get_pcvar_num( g_pNumSmokes );
g_Smoking |= ( 1 << ( id & 31 ) );
}
else
{
client_print( id , print_chat , "* Smoke count-down already running" );
return PLUGIN_HANDLED;
}
if ( !g_bThinking )
entity_set_float( g_Entity , EV_FL_nextthink , ( get_gametime() + 1.1 ) );
return PLUGIN_HANDLED;
}
public EntityThink( iEntity )
{
if ( iEntity == g_Entity )
{
new iPlayers[ 32 ] , iNum , id;
get_players( iPlayers , iNum , "ach" );
for ( new i = 0 ; i < iNum ; i++ )
{
id = iPlayers[ i ];
if ( g_Smoking & ( 1 << ( id & 31 ) ) )
{
set_hudmessage( 255 , 0 , 255 , -1.0 , 0.30 , 0 , 0.0 , 1.0 )
show_hudmessage( id , "[ %d second%s left ]" , g_iNumSmokes[ id ] , g_iNumSmokes[ id ] > 1 ? "s" : "" );
if ( --g_iNumSmokes[ id ] <= 0 )
{
g_Smoking &= ~( 1 << ( id & 31 ) );
}
}
}
if ( g_Smoking )
{
entity_set_float( g_Entity , EV_FL_nextthink , ( get_gametime() + 1.1 ) );
g_bThinking = true;
}
else
{
g_bThinking = false;
}
}
}
__________________