BREAKING NEWS

Welcome to File Townz | A TOWN Where you find all Files !

Search

Monday, 12 September 2016

How to make an simple ping kicker system

THIS TUTORIALS IS FOR NEWBIES
How to make an simple ping kicker system
1)first lets define the max ping(so you can change it easily)
Code:
#define MAX_PING        1000 //so this can be changed easily
2)setting a timer to check for the ping (under ongamemodeint or onfilterscriptint)
Code:
public OnGameModeInit()
{
    SetTimer("PingKick",5000,1);//Setting a timer to check for the players ping..5000 miliseconds = 5 secs
    return 1;
}
3)PingKick function
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
            }
        }
     }
}
hope you learned something

Share this:

Post a Comment

 
Copyright © 2014 Filetownz. Designed by OddThemes | Distributed By Gooyaabi Templates