[Tutorial] How to make an simple ping kicker system
#1

THIS TUTORIALS IS FOR NEWBIES
1)first lets define the max ping(so you can change it easily)
PHP Code:
#define MAX_PING        1000 //so this can be changed easily 
2)setting a timer to check for the ping (under ongamemodeint or onfilterscriptint)
PHP 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
PHP Code:
public PingKick()
{
    for(new 
0GetPlayerPoolSize(); <= ji++)//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(playeridnamesizeof(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
Reply


Messages In This Thread
How to make an simple ping kicker system - by xTURBOx - 27.01.2016, 16:15
Re: How to make an simple ping kicker system - by Su37Erich - 27.01.2016, 17:03
Re: How to make an simple ping kicker system - by Untonyst - 29.01.2016, 09:53
Re: How to make an simple ping kicker system - by VVWVV - 30.01.2016, 08:57

Forum Jump:


Users browsing this thread: 1 Guest(s)