SA-MP Forums Archive
Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help (/showthread.php?tid=594893)



Help - s3Nz0r - 25.11.2015

Problems encountered (description): Can not enter the server because ping picture below
Код:
//Anti High Ping
	//--------------------------------------------------------------------------
	foreach(new i: Player)
	{
		if(GetPlayerPing(i) > ServerInfo[MaxPing])
		{
		 	FormatMSG(i, COLOR_ULTRARED, "%s(%d) {FFFF00}has been auto-kicked for having a high ping.[{FF0000}%d/%d{FFFF00}]", PlayerName(i), i, GetPlayerPing(i), ServerInfo[MaxPing]);
		 	//------------------------------------------------------------------
		 	eLog[0] = EOS; format(eLog, sizeof(eLog), "%s has been auto-kicked for having a high ping.[%d/%d]", PlayerName(i), GetPlayerPing(i), ServerInfo[MaxPing]), SendLog(eLog), KickEx(i);
		}
	}
	//--------------------------------------------------------------------------
IMG/ http://i.imgur.com/KlUTw0O.png


Re: Help - lucamsx - 25.11.2015

What is your ServerInfo[MaxPing]?


Re: Help - itsCody - 25.11.2015

When you join the server the ping says 65535, which is the reason you're getting kicked.

Set a timer to check it every * seconds when they spawn.
https://sampwiki.blast.hk/wiki/GetPlayerPing


Re: Help - Vince - 25.11.2015

This is not a good way to implement a ping kicker system. One spike or invalid value (as said above) and the player is out. This is a very good way to lose players very quickly. To build a decent ping kicker you need to take several samples and calculate the average of these samples. The more samples the better. I would say at least 10, but maybe more.

PHP код:
CalculateAverage(const pieces[], totalAmount sizeof pieces)
{
    new 
sum 0;
    
    for(new 
itotalAmounti++)
    {
        
sum += pieces[i];
    }
    
    return 
sum totalAmount;




Re: Help - JimmyCh - 25.11.2015

As mentioned above, it is best to use timers for an effective ping system.
I would suggest setting a timer every 30 seconds, and if the ping is higher than your server's max ping implement 1... Until the guy gets 15 warnings, then kick him out.