How to fix the SPAM?
#1

Hello, i've added for my server a ping limit. So if player joins for example with 10 ping, he gets automaticly kicked. But when i test for myself, i get kick ,but the messages are just spaming at one time. I would like to have only one message..

Chatlog:

Код:
[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] [KICKED] Max ping exceeded <10>

[12:18:32] [KICK] Ercha has been kicked: Max Ping <10>

[12:18:32] Server closed the connection.

I scripted this "OnPlayerUpdate" how fix that message shows only time? Not spam.

Код:
public OnPlayerUpdate(playerid)
{
    new playername[MAX_PLAYER_NAME], string[128];
    if(GetPlayerPing(playerid) > 10 && GetPlayerPing(playerid) != 65535){
        GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
        SendClientMessage(playerid, COLOR_GREEN, "[KICKED] Max ping exceeded <10>");
        Kick(playerid);
        format(string, 128, "[KICK] %s has been kicked: Max Ping <10>", playername);
        SendClientMessageToAll(COLOR_RED, string);
    }
Thanks in advance!
Reply
#2

Doing this on OnPlayerUpdate is not a good idea I guess. Use a timer every 1 second.
Reply
#3

What do you mean? How to do that?
Reply
#4

Well you are kicking a user with > 10 ping
Reply
#5

https://sampwiki.blast.hk/wiki/SetTimer Duh...
https://sampwiki.blast.hk/wiki/SetTimerEx Duh...
Reply
#6

Quote:
Originally Posted by iJumbo
Посмотреть сообщение
Well you are kicking a user with > 10 ping
It's 10 because i wanted to see if this really works. I don't have ping like 300, but 20+.
Reply
#7

Quote:
Originally Posted by [EnErGyS]KING
Посмотреть сообщение
Explain how do i make it look like?
Reply
#8

pawn Код:
//Set it as local, the default MaxPing is 1050
new MPing = 1050; //Change the 1050 to any number you want ( 300+ )


//OnPlayerConnect

SetTimerEx("PingTimer", 40000, true, "i", playerid); //Sets a 40second timer

//Anywhere at your script (Not in a callback!)

forward PingTimer(playerid);

public PingTimer(playerid)

for(new i = 0; i < MAX_PLAYERS; i ++)
{
    if(IsPlayerConnected(i))
    {
        new ping = GetPlayerPing(i); //Gets ping
    if(ping > MPing) //If players ping is higher than Max.Ping
    {
        new name[MAX_PLAYER_NAME];
        GetPlayerName(i, name, sizeof(name));
        new string[128];
        format(string, sizeof(string), "* %s[%d] has been auto-kicked for having a high ping [%d/%d]", name, i, ping, MPing);
        SendClientMessageToAll(COLOR_YELLOW, string);
        SetTimerEx("KickTimer", 100, false, "i", i);
        return 1;
    }
    }
    return 1;
}

//KickTimer

public KickTimer(playerid)
{
    Kick(playerid);
    return 1;
}

//Additional command:

CMD:setping(playerid, params[]) {
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "* You need to be an admin to use this command!");
    new string[112];
    new newlimit;
    if(sscanf(params, "i", newlimit)) return SendClientMessage(playerid, COLOR_RED, "[USAGE] - /setping [PING-LIMIT]");
    MPing = newlimit;
    if(newlimit < 499) return SendClientMessage(playerid, COLOR_YELLOW, "[INFO] - The lowest ping limit is 500!"); //stuff
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(string, sizeof(string), "[PING] - Admin %s[%d] has changed the ping-limit to %i!", pName, playerid, newlimit);
    SendClientMessageToAll(COLOR_YELLOW, string);
    return 1;
}
..
Reply
#9

Imagine if his server had 50 people, so 50 timers. Also imagine 1 timer and 1 loop. Which case will be faster?
Reply
#10

You could possibly script it under server triggered events such as OnPlayerKeyStateChange (trying to aim or shoot) or OnPlayerStreamIn (coming in to view of another player).
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)