3D Label won't delete
#1

I have this afk notifier, that when you go AFK, shows a 3D text label above player's head that says "AFK". Now sometimes the AFK label stays there and doesn't delete when the player returns.

This is my code:

When the player goes AFK (timer, every 10 seconds)
pawn Код:
AFK[playerid] += 1;
            if(AFK[playerid] > 1)
            {
                if(AFK[playerid] >= 90 && !IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pGM] < 1)
                {
                    KickPlayer(playerid,"SYSTEM","AFK");
                    return 1;
                }
                if(AFK[playerid] > 2)
                {
                    new str[25];format(str, 25, "AFK (%d seconds)", AFK[playerid]*10);
                    Update3DTextLabelText(AFKlabel[playerid],COLOR_ORANGE, str);
                    return 1;
                }
                if(AFK[playerid] > 1)
                {
                    new str[25];format(str, 25, "AFK (%d seconds)", AFK[playerid]*10);
                    AFKlabel[playerid] = Create3DTextLabel(str, COLOR_ORANGE, 30.0, 40.0, 50.0, 40.0, 0, 0);
                    Attach3DTextLabelToPlayer(AFKlabel[playerid], playerid, 0.0, 0.0, 0.35);
                    IsPlayerAFK[playerid] = true;
                    return 1;
                }
            }
OnPlayerUpdate
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(IsPlayerAFK[playerid])
    {
        Delete3DTextLabel(AFKlabel[playerid]);
        IsPlayerAFK[playerid] = false;
    }
    AFK[playerid] = 0;
    return 1;
}
OnPlayerDisconnect
pawn Код:
if(IsPlayerAFK[playerid] == true)
        {
// IsPlayerAFK gets reset when to false when player connects
            Delete3DTextLabel(AFKlabel[playerid]);
        }
Sometimes it just stands there and doesn't get deleted, and another one shows over the old one when the player is afk.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)