GetPlayerPing bug
#1

pawn Код:
if(GetPlayerPing(playerid) > 300) {
            new PlayerName[24];
            GetPlayerName(playerid, PlayerName, 24);
            foreach(Player, i) {
                format(String, sizeof(String), LoadText(i, "PING_KICK"), PlayerName, playerid);
                SendClientMessage(i ,COLOR_LIGHTRED, String);
            }
            Kick(playerid);
        }
It checks every one second.
The problem is that it kicks even if i have 40 ping
Reply
#2

It's not a bug, it's your code.
pawn Код:
foreach(Player, i) {
if(GetPlayerPing(i) > 300) {
Kick(i);
}
}
Reply
#3

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
It's not a bug, it's your code.
pawn Код:
foreach(Player, i) {
if(GetPlayerPing(i) > 300) {
Kick(i);
}
}
Well, you're wrong.

foreach(Player, playerid) - it will be the same.

You can use other int than 'i' if you didnt know
Reply
#4

I'm using this code and it works perfect.

OnPlayerConnect:
pawn Код:
SetTimerEx("PingCheck", 1000, 1, "i", playerid);
Somewhere in your script.
pawn Код:
forward PingCheck(playerid);
public PingCheck(playerid)
{
    new string[256];
    new ping = GetPlayerPing(playerid);
    new playrname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playrname, sizeof(playrname));
    if(ping > 300)
    {
        format(string, sizeof(string), "\"%s\" has been kicked by Server. Reason: (High Ping) (His Ping: %d  | Maximum: 300)", playrname, ping);
        SendClientMessageToAll(0xFFFF00FF, string);
        Kick(playerid);
    }
}
Reply
#5

Also note that the players ping could be like 9999 several seconds after he/she connected.
Reply
#6

Quote:
Originally Posted by Clive
Посмотреть сообщение
I'm using this code and it works perfect.

OnPlayerConnect:
pawn Код:
SetTimerEx("PingCheck", 1000, 1, "i", playerid);
Somewhere in your script.
pawn Код:
forward PingCheck(playerid);
public PingCheck(playerid)
{
    new string[256];
    new ping = GetPlayerPing(playerid);
    new playrname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playrname, sizeof(playrname));
    if(ping > 300)
    {
        format(string, sizeof(string), "\"%s\" has been kicked by Server. Reason: (High Ping) (His Ping: %d  | Maximum: 300)", playrname, ping);
        SendClientMessageToAll(0xFFFF00FF, string);
        Kick(playerid);
    }
}
I will try your code, but it's practically the same.
Reply
#7

Quote:
Originally Posted by _rAped
Посмотреть сообщение
Also note that the players ping could be like 9999 several seconds after he/she connected.
When a player connects their ping is 65535 and it takes about a second or two for it to resolve to their normal ping. Add an additional variable and add on to it every second, after two or three seconds then check their ping and allow your timer to keep checking whether the player has been connected for long enough to be ping kicked.
Reply
#8

Quote:
Originally Posted by Calgon
Посмотреть сообщение
When a player connects their ping is 65535 and it takes about a second or two for it to resolve to their normal ping. Add an additional variable and add on to it every second, after two or three seconds then check their ping and allow your timer to keep checking whether the player has been connected for long enough to be ping kicked.
That's what I ment just coulden't remember the exact number, thank you
Reply
#9

I've seen alot of people having 65535 ping, well just do a SetTimerEx under OnPlayerSpawn with repeating on.
Reply
#10

Quote:
Originally Posted by Mean
Посмотреть сообщение
I've seen alot of people having 65535 ping, well just do a SetTimerEx under OnPlayerSpawn with repeating on.
That's generally inefficient, you could quite possibly end up with 500 timers. You should create a variable and set its value once a player has spawned, and a timer (containing a loop) will check the value and kick the player if the value is set and their ping is excessive.

Unrelated to the topic, I think you should re-consider the ping limit, 300 isn't too bad for a ping anyway - 500+ is.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)