SA-MP Forums Archive
Ping Checker - 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: Ping Checker (/showthread.php?tid=347250)



Ping Checker - JaKe Elite - 01.06.2012

Hello,
I need help with my Ping Checker,
it warns me even i set the max ping to 0

How to fix with this issue?

pawn Код:
//OnGameModeInit

Ping = SetTimer("PingChecker", 5000, true);

//OnGameModeExit

KillTimer(Ping);

forward PingChecker();
public PingChecker()
{
    new str[128];
    foreach(Player, i)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerPing(i) > dini_Int("Clan/Config/serverconfg.cfg", "MaxPing"))
            {
                if(pData[i][Warn] == MAX_WARNINGS)
                {
                    format(str, sizeof(str), "%s(%d) has been kicked from the server for Reaching Maxium Ping (Ping: %d | Maxium Ping: %d)", GetpName(i), i, GetPlayerPing(i), dini_Int("Clan/Config/serverconfg.cfg", "MaxPing"));
                    SendClientMessageToAll(COLOR_RED, str);
                    Kick(i);
                }
                pData[i][Warn]++;
                format(str, sizeof(str), "[PING] %s(%d) has recieved a Ping Warning (Warnings: %d/%d)", GetpName(i), i, pData[i][Warn], MAX_WARNINGS);
                SendClientMessageToAll(COLOR_YELLOW, str);
            }
        }
    }
    return 1;
}

CMD:setmaxping(playerid, params[])
{
    new str[128], maxping;
    if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
    if(pData[playerid][Admin] >= 4 || IsPlayerAdmin(playerid))
    {
        if(sscanf(params, "i", maxping))
        {
            SendClientMessage(playerid, COLOR_RED, "USAGE: /setmaxping [Ping]");
            SendClientMessage(playerid, COLOR_RED, "Note: "white"If you want to disable the Ping Kicker just do /setmaxping 0");
            return 1;
        }
        sData[MaxPing] = maxping;
        dini_IntSet("Clan/Config/serverconfg.cfg", "MaxPing", sData[MaxPing]);
        foreach(Player, i)
        {
            format(str, sizeof(str), "~w~Max Ping ~r~set ~w~to ~y~%d", maxping);
            GameTextForPlayer(i, str, 4000, 3);
            PlayerPlaySound(i,1057,0.0,0.0,0.0);
        }
        if(maxping == 0)
        {
            format(str, sizeof(str), "Administrator %s(%d) has disable maxium ping!", GetpName(playerid), playerid);
            SendClientMessageToAll(COLOR_YELLOW, str);
            return 1;
        }
        format(str, sizeof(str), "Administrator %s(%d) has set maxium ping to %d", GetpName(playerid), playerid, maxping);
        SendClientMessageToAll(COLOR_RED, str);
        format(str, sizeof(str), "ADMMSG: Administrator %s(%d) has use /setmaxping", GetpName(playerid), playerid);
        ReadADMCMD(playerid, COLOR_BLUE, str);
    }
    else return SendClientMessage(playerid, COLOR_RED, "*** You are not Head Administrator ***");
    return 1;
}



Re: Ping Checker - iJumbo - 01.06.2012

Try store the MaxPing in a var ..


Re: Ping Checker - Vince - 01.06.2012

Quote:
Originally Posted by Romel
Посмотреть сообщение
it warns me even i set the max ping to 0

pawn Код:
if(GetPlayerPing(i) > dini_Int("Clan/Config/serverconfg.cfg", "MaxPing"))
Well duh ...
May I say that is a terrible way of doing this? (Why do people keep using dini in the first place?) You should fetch the value once and store it prior to starting the loop. This codes opens the file 500 times which is incredibly slow.


Re: Ping Checker - HuSs3n - 01.06.2012

replace
pawn Код:
if(GetPlayerPing(i) > dini_Int("Clan/Config/serverconfg.cfg", "MaxPing"))
with
pawn Код:
if(GetPlayerPing(i) > 800)
if the issue is fixed then the problem is with dini_Int


Re: Ping Checker - iJumbo - 01.06.2012

when you change maxping save in a var and in the file .. when you start the gamemode you can load it ..


Re: Ping Checker - JaKe Elite - 01.06.2012

I'm still beginner yet, so how to do it, jumbo?


Re: Ping Checker - iJumbo - 01.06.2012

You already have this when you set the maxping .. ..
Код:
sData[MaxPing] = maxping
SO you can do

Код:
 if(GetPlayerPing(i) > sData[MaxPing])



Re: Ping Checker - JaKe Elite - 01.06.2012

Look if i do that i still get the Ping Checker Warning and this time

Код:
(Ping: 17 | Maxium Ping: 0)
it must be

Код:
(Ping: 34 | Maxium Ping: 30)
so thats why i'm not doing that way...


Re: Ping Checker - iJumbo - 01.06.2012

This sData[MaxPing] is not 0 if you set it .....


Re: Ping Checker - JaKe Elite - 01.06.2012

What you mean?

In my file serverconfg.cfg my MaxPing is set to 30
when setting with /setmaxping it set to 30 too.