How do I kick players who have over 200 ping
#1

Hello everyone I am very new to scripting and I have a question, how do I use GetPlayerPing so it kicks players who have over 200 ping? I attempted to script it but it gave me a bunch of errors and I have no idea where to put the functions etc and if it's meant to go in OnGameModeInit or elsewhere so yeah I have no idea about scripting and thats why I am asking I hope someone can help me with this problem.

The code so far is :

public OnPlayerConnect(playerid)
{
SetTimerEx("PingCheck", 1000, 1, "i", playerid);

return 1;
}
Reply
#2

You don't have to use a timer for that purpose, a simple condition under OnPlayerUpdate would work perfectly fine as it's not much of a code either!

So an if conditions is really simple:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPlayerPing(playerid) > 200) {
        // kick goes in here, message etc
    }
        return 1;
}
Reply
#3

What happens when a player has just connected with 65535 ping? They get kicked using your example. It should also be noted some players do have 200 ping when they're not even lagging just because of where they live. Pings can be as high as 800 to be fair if they are very far from the server.
Reply
#4

Quote:
Originally Posted by PaulDinam
Посмотреть сообщение
You don't have to use a timer for that purpose, a simple condition under OnPlayerUpdate would work perfectly fine as it's not much of a code either!

So an if conditions is really simple:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(GetPlayerPing(playerid) > 200) {
        // kick goes in here, message etc
    }
        return 1;
}
ok thanks a bunch the GetPlayerPing most likely will work now but I still don't know which code it is to kick the player I tried to write Kick in (// kick goes in here pawn, message etc) but it gave me an error
Reply
#5

Quote:
Originally Posted by Abagail
Посмотреть сообщение
What happens when a player has just connected with 65535 ping? They get kicked using your example. It should also be noted some players do have 200 ping when they're not even lagging just because of where they live. Pings can be as high as 800 to be fair if they are very far from the server.
ok thanks Avagail I will change it to 800 but I still have a question of how to kick the player I dont know which code to use to kick him/her
Reply
#6

Kick(playerid);
Reply
#7

Quote:
Originally Posted by Abagail
Посмотреть сообщение
What happens when a player has just connected with 65535 ping? They get kicked using your example. It should also be noted some players do have 200 ping when they're not even lagging just because of where they live. Pings can be as high as 800 to be fair if they are very far from the server.
True. This happened to me when I did the same thing, kick the player if their ping is over x.

To fix this issue, add a simple timer when player connects to the server. Set the interval to, i.e. 10 seconds and when the timer ends, set some boolean variable to true. If the variable is true and player's ping is over x, kick the player.
Reply
#8

Even 800 can be a low value, something such as 1500 or 2000 however is definitely an issue not related to distance.
Reply
#9

800 is not low. Most players from across the globe average 350 to 450.

This is also a terrible method for a ping kicker. One spike or glitch (infamous 65535) and it's game over. Take samples continuously and calculate the average. If the ping is high for a continued period of time then you can kick.
Reply
#10

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
Kick(playerid);
Thanks gamesbond007 the code works

Quote:
Originally Posted by Vince
Посмотреть сообщение
800 is not low. Most players from across the globe average 350 to 450.

This is also a terrible method for a ping kicker. One spike or glitch (infamous 65535) and it's game over. Take samples continuously and calculate the average. If the ping is high for a continued period of time then you can kick.
ok cheers how do I take samples of a ping on a private server I created mine in hamachi
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)