#include < amxmodx >
static const PLUGIN_NAME[ ] = "Advanced Ping / Check";
static const PLUGIN_VERSION[ ] = "0.3";
static const tTag[ ] = "AdvancedPing";
new aPc_Cmd_NoLag[ ][ ] = { "ex_interp 0.01", "fps_max 101", "fps_modem 101", "developer 1", "rate 25000", "echo Ti`am aplicat cu succes setariile anti-lag." };
new g_CvarTask, g_CvarMaxPing;
new tPingWarn[ 33 ];
#pragma semicolon 1
public plugin_init( )
{
register_plugin( PLUGIN_NAME, PLUGIN_VERSION, "puMf" );
g_CvarTask = register_cvar( "advanced_ping_task", "3.0" );
g_CvarMaxPing = register_cvar( "advanced_ping_maxping", "80" );
set_task( get_pcvar_float( g_CvarTask ) , "check_ping", _, _, _, "b", _ );
register_dictionary( "advanced_ping_check.txt" );
}
public check_ping( )
{
new tPing, tLoss, i_Index, tPlayers[ 32 ], tNum;
get_players( tPlayers, tNum, "c" );
for( new i=0;i < tNum; i++ )
{
i_Index = tPlayers[ i ];
if( is_user_connected( i_Index ) )
{
get_user_ping( i_Index, tPing, tLoss );
if( tPing > get_pcvar_num( g_CvarMaxPing ) )
{
PlayerWarn( i_Index );
}
}
}
}
PlayerWarn( i_Index )
{
new tName[ 32 ];
get_user_name( i_Index, tName, 31 );
new tPing, tLoss;
get_user_ping( i_Index, tPing, tLoss );
tPingWarn[ i_Index ]++;
switch( tPingWarn[ i_Index ] )
{
case 1:
{
puMf_Color_Chat( i_Index, "%L", LANG_PLAYER, "APC_WARN_1", tPing );
for( new i=0;i < sizeof( aPc_Cmd_NoLag ); i++ )
{
client_cmd( i_Index, aPc_Cmd_NoLag[ i ] );
}
}
case 2:
{
puMf_Color_Chat( i_Index, "%L", LANG_PLAYER, "APC_WARN_2", tPing, get_pcvar_num( g_CvarMaxPing ), tPingWarn[ i_Index ], 3 );
}
default:
{
server_cmd( "kick #%d Cand rezolvi ping`ul / lag`ul revin`o la joc.[W: %d/%d]", get_user_userid( i_Index ), tPingWarn[ i_Index ], 3 );
}
}
log_to_file( "advanced_check_ping.log", "-= %s =- A fost prins cu PING -= %d =- si LOSS -= %d =-", tName, tPing, tLoss );
}
public client_disconnect( i_Index ) { tPingWarn[ i_Index ] = 0; }
public client_putinserver( i_Index ) { tPingWarn[ i_Index ] = 0; }
stock puMf_Color_Chat( const id, const input[], any:... )
{
new tCount = 1, tPlayers[ 32 ];
static tMsg[ 320 ], tMsg2[ 320 ];
vformat( tMsg, 190, input, 3 );
format( tMsg2, 190, "!c[!v%s!c] %s", tTag, tMsg );
replace_all( tMsg2, 190, "!v", "^4" );
replace_all( tMsg2, 190, "!c", "^1" );
replace_all( tMsg2, 190, "!e", "^3" );
replace_all( tMsg2, 190, "!e2", "^0" );
if( id )
{
tPlayers[ 0 ] = id;
}
else
{
get_players( tPlayers, tCount, "ch" );
}
for( new f=0;f < tCount; f++ )
{
if( is_user_connected( tPlayers[ f ] ) )
{
message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, tPlayers[ f ] );
write_byte( tPlayers[ f ] );
write_string( tMsg2 );
message_end( );
}
}
}