What's wrong with this AFK kicker?
#1

I run this on a 10 second timer

pawn Код:
AFK[playerid] += 1;
        if(AFK[playerid] > 1)
        {
            if(AFK[playerid] > 2)
            {
                new str[25];format(str, 25, "AFK (%d seconds)", AFK[playerid]*10);
                Update3DTextLabelText(AFKlabel[playerid], 0xFF000000, str);
                return 1;
            }
            if(AFK[playerid] >= 120)
            {
                KickPlayer(playerid,"SYSTEM","AFK");
                return 1;
            }
            else
            {
                AFKlabel[playerid] = Create3DTextLabel("AFK (20 seconds)", 0xFF000000, 30.0, 40.0, 50.0, 40.0, 0, 0);
                Attach3DTextLabelToPlayer(AFKlabel[playerid], playerid, 0.0, 0.0, 0.5);
            }
        }
And this is my OnPlayerUpdate
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(AFK[playerid] > 1)
    {
        Delete3DTextLabel(AFKlabel[playerid]);
    }
    AFK[playerid] = 0;
}
When I go AFK, the 3D label isn't shown :/
Reply
#2

I think the label is only shown for other players (not for yourself).
I use the same method for my ranks.
Reply
#3

If I'm not wrong, OnPlayerUpdate is called even when you're not moving anything, but less times. So, that's the reason why your variable is set to 0 again and again.

A suggestion, you should check player animation for that, and if it's the same as the last time count up. I think the anim is called crry_prtial, from CARRY library.

Good luck!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)