14.01.2013, 22:17
pawn Код:
forward PingKick();
public PingKick()
{
if(ServerInfo[MaxPing] != 0)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
AccInfo[i][pPing] = GetPlayerPing(i);
if(GetPlayerPing(i) > ServerInfo[MaxPing])
{
if(AccInfo[i][PingCount] == 0) AccInfo[i][PingTime] = TimeStamp();
AccInfo[i][PingCount]++;
if(TimeStamp() - AccInfo[i][PingTime] > PING_TIMELIMIT)
{
AccInfo[i][PingTime] = TimeStamp();
AccInfo[i][PingCount] = 1;
}
else if(AccInfo[i][PingCount] >= PING_MAX_EXCEEDS)
{
new Sum, Average, x, string[128];
while (x < PING_MAX_EXCEEDS) {
Sum += AccInfo[i][pPing][x];
x++;
}
Average = (Sum / PING_MAX_EXCEEDS);
format(string,sizeof(string),"%s has been kicked from the server. (Reason: High Ping (%d) | Average (%d) | Max Allowed (%d) )", PlayerName2(i), GetPlayerPing(i), Average, ServerInfo[MaxPing] );
SendClientMessageToAll(grey,string);
Kick(i);
}
}
}
}
}