27.04.2014, 03:26
(
Last edited by Eth; 27/04/2014 at 10:01 AM.
)
What do you need is:
a_samp
Ok let's start , first of all we have to define the max ping and the max pl allowed in your server (pl = pocket loss)
so at the top of you script:
you can edit it with your own ping and packet loss:
on gamemodeinit:
and now the last thing, the timerut it in any place in your gamemode:
and the last thing:
it's just a simple timer to kick laggers, if there is no admin online :d ty for checking my post.
Edit:
special thanks to : Djole1337 for telling me the bug on this tutorial
a_samp
Ok let's start , first of all we have to define the max ping and the max pl allowed in your server (pl = pocket loss)
so at the top of you script:
you can edit it with your own ping and packet loss:
pawn Code:
#define MAX_PING 1000 // Max Ping
#define MAX_PL 1.0 // Max Packet Loss
forward CheckStats();//for the timer
new Timer;//the define for the timer
#define COLOR_RED 0xFF0000AA //the color we are going to use on this tutorial
pawn Code:
Timer = SetTimer("CheckStats", 1000, true);//will start the timer when the server starts
pawn Code:
public CheckStats()
{
for (new i = 0; i != MAX_PLAYERS; ++ i)
{
if (IsPlayerConnected(i))
{
if(GetPlayerPing(i) > MAX_PING)//get the player ping more than the maximum ping allowed in server
{
new string[257];
format(string,sizeof(string),"{FF0000}Player{FFFFFF}[%s] has been kicked for exceeding ping limit [%d/%d]",GetName(i),GetPlayerPing(i),MAX_PING);//the format for a message to all players
SendClientMessageToAll(COLOR_RED,string);//and the message
Kick(i);//will kick him
}
if(GetPlayerPacketLoss(i) > MAX_PL)//get the player pl more than the maximum pl allowed in server
{
new string[257];
format(string,sizeof(string),"{FF0000}Player{FFFFFF}[%s] has been kicked for exceeding packetloss limit [%d/%d]",GetName(i),GetPlayerPacketLoss(i),MAX_PL);//the format for a message to all players
SendClientMessageToAll(COLOR_RED,string);//the message
Kick(i);//will kick him
}
}
return 1;
}
pawn Code:
forward Float:GetPlayerPacketLoss(playerid);//forward for the packetloss
stock Float:GetPlayerPacketLoss(playerid)//the stock
{
new stats[401], stringstats[70];//those are the variables we will need in the stock
GetPlayerNetworkStats(playerid, stats, sizeof(stats));//this one will get the net stats
new len = strfind(stats, "Packetloss: ");//and this one will get the packetloss
new Float:packetloss = 0.0;//the float for the packetloss
if(len != -1)
{
strmid(stringstats, stats, len, strlen(stats));
new len2 = strfind(stringstats, "%");
if(len != -1)
{
strdel(stats, 0, strlen(stats));
strmid(stats, stringstats, len2-3, len2);
packetloss = floatstr(stats);
}
}
return packetloss;
}
Edit:
special thanks to : Djole1337 for telling me the bug on this tutorial