NetStats_PacketLossPercent()
#1

I was testing this function to implement a packetloss kicker and found it to be completely unreliable here is the code.

pawn Код:
#include <YSI\y_hooks>

#define         PACKET_LOSS_DELAY           60000
#define         PACKET_LOSS_INFRACTIONS     3

static Float:LastPacketLoss[MAX_PLAYERS];
static PacketLossTime[MAX_PLAYERS];
static PacketLossInfractions[MAX_PLAYERS];

hook OnGameModeInit()
{
    SetTimer("LossChecker", 1000, true);
    return 1;
}

hook OnPlayerConnect(playerid)
{
    LastPacketLoss[playerid] = 0.0;
    PacketLossTime[playerid] = GetTickCount();
    PacketLossInfractions[playerid] = 0;
    return 1;
}

LossChecker();
public LossChecker()
{
    new Float:loss;
    foreach(new i : Player)
    {
        loss = NetStats_PacketLossPercent(i);

        // Loss detected
        if(loss > LastPacketLoss[i])
        {
            if(GetTickCount() - PacketLossTime[i] > PACKET_LOSS_DELAY) PacketLossInfractions[i] = 1;
            else PacketLossInfractions[i]++;
            PacketLossTime[i] = GetTickCount();
           
            if(PacketLossInfractions[i] == PACKET_LOSS_INFRACTIONS)
            {
                Disconnect_Reason[i] = DISCONNECT_PACKETLOSS;
                DelayKick(i);
            }
        }
        LastPacketLoss[i] = loss;
    }
    return 1;
}
Reply


Messages In This Thread
NetStats_PacketLossPercent() - by Pottus - 21.09.2014, 01:35
Re: NetStats_PacketLossPercent() - by n0minal - 21.09.2014, 05:08
Re: NetStats_PacketLossPercent() - by Tamer - 21.09.2014, 07:11
Re: NetStats_PacketLossPercent() - by Pottus - 21.09.2014, 14:41
Re: NetStats_PacketLossPercent() - by Whitetiger - 21.09.2014, 15:02
Re: NetStats_PacketLossPercent() - by rymax99 - 21.09.2014, 15:36

Forum Jump:


Users browsing this thread: 1 Guest(s)