SA-MP Forums Archive
What's wrong with this AFK kicker? - 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: What's wrong with this AFK kicker? (/showthread.php?tid=367853)



What's wrong with this AFK kicker? - Makaveli93 - 11.08.2012

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 :/


Re: What's wrong with this AFK kicker? - jeremy8810 - 11.08.2012

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


Respuesta: What's wrong with this AFK kicker? - [DOG]irinel1996 - 11.08.2012

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!