THIS TUTORIALS IS FOR NEWBIES
How to make an simple ping kicker system |
Code:
#define MAX_PING 1000 //so this can be changed easily
Code:
public OnGameModeInit()
{
SetTimer("PingKick",5000,1);//Setting a timer to check for the players ping..5000 miliseconds = 5 secs
return 1;
}
Code:
public PingKick()
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)//looping through players
{
if(IsPlayerConnected(i))//to see whether the player is connected
{
if(GetPlayerPing(i) > MAX_PING)//checking for the ping( and continuing if ping is above max ping)
{
new string[128],name[MAX_PLAYER_NAME];//some variables for string and playername
GetPlayerName(playerid, name, sizeof(name));//formatting the variable name with the name of the player
format(string,sizeof(string),"PING-KICK:%s(%d) has automatically been kicked. Reason: {00FFFF}High Ping(%d / %d)",name,i,GetPlayerPing(i),MAX_PING);//formatting a message to send
SendClientMessageToAll(-1,string);//sending the formatted messaage
Kick(i);//kicking the player with High ping
}
}
}
}
Post a Comment