/*
Plugin creat pentru fun.
Cvaruri:
buzz_sec_shake - cat timp sa-i tremure ecranul (default: 15.0) (il treceti cu decimale)
buzz_sec_delay - delayul intre comenzi (default: 15)
*/
#include < amxmodx >
#include < amxmisc >
#define PLUGIN_NAME "Buzz to player"
#define PLUGIN_VERSION "1.1"
#define PLUGIN_AUTHOR "falseq"
new g_SecShakeScreen, g_DelaySeconds;
new g_Delay[ 33 ];
public plugin_init( )
{
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
register_cvar( "bp_author", PLUGIN_AUTHOR, FCVAR_SERVER | FCVAR_SPONLY );
set_cvar_string( "bp_author", PLUGIN_AUTHOR );
register_clcmd( "say", "Func_Say" );
register_clcmd( "say_team", "Func_Say" );
register_concmd( "amx_buzz", "Func_Buzz", _, _ );
g_SecShakeScreen = register_cvar( "buzz_sec_shake", "15.0" );
g_DelaySeconds = register_cvar( "buzz_sec_delay", "15" );
}
public Func_Say( id )
{
new szSaid[ 192 ];
read_args( szSaid, sizeof( szSaid ) -1 );
remove_quotes( szSaid );
if( contain( szSaid, "/buzz" ) != -1 )
{
if( g_Delay[ id ] > time( ) )
{
new iTime = g_Delay[ id ] - time( );
C_PrintChat( id, "Asteapta !v%i!c secund%s, pana poti folosi !vbuzz!c din nou.", iTime, iTime == 1 ? "a" : "e" );
}
else
{
new target[ 32 ];
copy( target, sizeof( target ) -1, szSaid[ 6 ] );
new iPlayer = cmd_target( id, target, 3 );
if( !iPlayer )
{
C_PrintChat( id, "Playerul ales de tine este !vinvalid!c." );
}
else
{
new szNameP1[ 32 ], szNameP2[ 32 ];
get_user_name( id, szNameP1, sizeof( szNameP1 ) -1 );
get_user_name( iPlayer, szNameP2, sizeof( szNameP2 ) -1 );
C_PrintChat( 0, "!v%s!c !eBUZZ!c !v%s!c.", szNameP1, szNameP2 );
C_PrintChat( iPlayer, "Ai primit !eBUZZ!c de la !v%s!c.", szNameP1 );
ShakeScreen( iPlayer, get_pcvar_float( g_SecShakeScreen ) );
}
g_Delay[ id ] = time( ) + get_pcvar_num( g_DelaySeconds );
}
}
}
public Func_Buzz( id )
{
if( get_user_flags( id ) & ADMIN_SLAY )
{
new szArg[ 32 ];
read_argv( 1, szArg, sizeof( szArg ) -1 );
new iPlayer = cmd_target( id, szArg, 3 );
if( !iPlayer || is_user_bot( iPlayer ) )
return PLUGIN_HANDLED;
new szNameP1[ 32 ], szNameP2[ 32 ];
get_user_name( id, szNameP1, sizeof( szNameP1 ) -1 );
get_user_name( iPlayer, szNameP2, sizeof( szNameP2 ) -1 );
C_PrintChat( 0, "!v%s!c !eBUZZ!c !v%s!c.", szNameP1, szNameP2 );
C_PrintChat( iPlayer, "Ai primit !eBUZZ!c de la !v%s!c.", szNameP1 );
ShakeScreen( iPlayer, get_pcvar_float( g_SecShakeScreen ) );
}
else
{
C_PrintChat( id, "Trebuie sa fi admin pentru a accesa aceasta comanda." );
}
return PLUGIN_HANDLED;
}
/* =======================================================================================================
=> Stock
=========================================================================================================== */
stock ShakeScreen( id, const Float:iSeconds )
{
message_begin( MSG_ONE, get_user_msgid( "ScreenShake" ), { 0, 0, 0 }, id );
write_short( floatround( 4096.0 * iSeconds, floatround_round ) );
write_short( floatround( 4096.0 * iSeconds, floatround_round ) );
write_short( 1 << 13 );
message_end( );
}
stock C_PrintChat( const id, const szInput[ ], any:... )
{
new iPlayers[ 32 ], iNum = 1;
new szMsg[ 320 ], szMsg2[ 320 ];
vformat( szMsg, sizeof( szMsg ) -130, szInput, 3 );
format( szMsg2, sizeof( szMsg2 ) -130, "!c[!vHide!c-!vN!c-!vSeek!c] %s", szMsg );
replace_all( szMsg2, sizeof( szMsg ) -130, "!v", "^x04" );
replace_all( szMsg2, sizeof( szMsg ) -130, "!c", "^x01" );
replace_all( szMsg2, sizeof( szMsg ) -130, "!e", "^x03" );
if( id )
{
iPlayers[ 0 ] = id;
}
else
{
get_players( iPlayers, iNum, "c" );
}
for( new i = 0; i < iNum; i++ )
{
if( is_user_connected( iPlayers[ i ] ) )
{
message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, iPlayers[ i ] );
write_byte( iPlayers[ i ] );
write_string( szMsg2 );
message_end( );
}
}
}