AFK timer
#1

Hi, I am wanting to make an AFK timer so at every second it updates, for example:

I go AFK then a 3DTextLabel appears on me saying "Luis has been AFK for 4 seconds" and I want it to update the seconds at each second of the SetTimer.

The code.
pawn Код:
public OnPlayerPause(playerid)
{
    new name[MAX_PLAYER_NAME], string[44], Float:Pos[3];
    GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
    IsAFK[playerid] = 1;
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s is AFK.", name);
    CreatePlayer3DTextLabel(playerid, string, COLOR_WHITE, Pos[0], Pos[1], Pos[2], 10.0);
    print(string);
    AFKTime[playerid] = SetTimerEx("AFKTimer", 1000, true, "i", playerid);
    return 0;
}

forward AFKTimer(playerid);
public AFKTimer(playerid)
{
    new seconds[MAX_PLAYERS], string[128];
    new secs = seconds[playerid]++;
    format(string, sizeof(string), "%s has been AFK for %d.", PlayerName(playerid), secs);
    UpdatePlayer3DTextLabelText(playerid, AFK, COLOR_WHITE, string);
    print(string);
    return 1;
}
Reply


Messages In This Thread
AFK timer - by Luis- - 02.10.2011, 14:22
Re: AFK timer - by Pharrel - 02.10.2011, 14:30
Re: AFK timer - by Luis- - 02.10.2011, 14:33
Re: AFK timer - by Pharrel - 02.10.2011, 14:35
Re: AFK timer - by Luis- - 02.10.2011, 14:37
Re: AFK timer - by suhrab_mujeeb - 02.10.2011, 14:40
Re: AFK timer - by Luis- - 02.10.2011, 14:41
Re: AFK timer - by suhrab_mujeeb - 02.10.2011, 14:47
Re: AFK timer - by Cypress - 02.10.2011, 14:49
Re: AFK timer - by suhrab_mujeeb - 02.10.2011, 14:50

Forum Jump:


Users browsing this thread: 5 Guest(s)