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
#2

new TimerAFK[MAX_PLAYERS]; //at the top

pawn Код:
TimerAFK[playerid] = SetTimerEx("AFKTimer", 1000,true,"i",playerid);//when he go out the afk use->

KillTimer(TimerAFK[playerid]);
i just made the timer, i didnt read your code
Reply
#3

I already have that, please read the code next time.
Reply
#4

AFKTime you already have the public with that name...

you got

new AFKTime
and
forward AFKTime
....
Reply
#5

No, I have new AFKTime[MAX_PLAYERS] and forward AFKTimer(playerid).
Reply
#6

Well he wants something like an AFK timer getter, so that for example I do /afk then it starts storing the time till I do /back and then it sends client a message " He is back after %i minutes"
Reply
#7

Yes, that is what I need, I have tried "new seconds++;" and "new seconds += 1;" and had no luck with both.
Reply
#8

Quote:
Originally Posted by -Luis
Посмотреть сообщение
Yes, that is what I need, I have tried "new seconds++;" and "new seconds += 1;" and had no luck with both.
You haven't created a loop. How do you expect to get the seconds increasing without a loop. Seriously dude, reading your I don't have an imagination.. and seeing your codes, I advise you to get some rest and try to get some refreshments.
Reply
#9

Quote:
Originally Posted by suhrab_mujeeb
Посмотреть сообщение
You haven't created a loop. How do you expect to get the seconds increasing without a loop. Seriously dude, reading your I don't have an imagination.. and seeing your codes, I advise you to get some rest and try to get some refreshments.
Why does he need to create a loop?
Reply
#10

Quote:
Originally Posted by Cypress
Посмотреть сообщение
Why does he need to create a loop?
In the new function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)