17.02.2014, 10:55
pawn Код:
//Set it as local, the default MaxPing is 1050
new MPing = 1050; //Change the 1050 to any number you want ( 300+ )
//OnPlayerConnect
SetTimerEx("PingTimer", 40000, true, "i", playerid); //Sets a 40second timer
//Anywhere at your script (Not in a callback!)
forward PingTimer(playerid);
public PingTimer(playerid)
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerConnected(i))
{
new ping = GetPlayerPing(i); //Gets ping
if(ping > MPing) //If players ping is higher than Max.Ping
{
new name[MAX_PLAYER_NAME];
GetPlayerName(i, name, sizeof(name));
new string[128];
format(string, sizeof(string), "* %s[%d] has been auto-kicked for having a high ping [%d/%d]", name, i, ping, MPing);
SendClientMessageToAll(COLOR_YELLOW, string);
SetTimerEx("KickTimer", 100, false, "i", i);
return 1;
}
}
return 1;
}
//KickTimer
public KickTimer(playerid)
{
Kick(playerid);
return 1;
}
//Additional command:
CMD:setping(playerid, params[]) {
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "* You need to be an admin to use this command!");
new string[112];
new newlimit;
if(sscanf(params, "i", newlimit)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setping [PING-LIMIT]");
MPing = newlimit;
if(newlimit < 499) return SendClientMessage(playerid, COLOR_YELLOW, "[INFO] - The lowest ping limit is 500!"); //stuff
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "[PING] - Admin %s[%d] has changed the ping-limit to %i!", pName, playerid, newlimit);
SendClientMessageToAll(COLOR_YELLOW, string);
return 1;
}