AFK timer -
Luis- - 02.10.2011
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;
}
Re: AFK timer -
Pharrel - 02.10.2011
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
Re: AFK timer -
Luis- - 02.10.2011
I already have that, please read the code next time.
Re: AFK timer -
Pharrel - 02.10.2011
AFKTime you already have the public with that name...
you got
new AFKTime
and
forward AFKTime
....
Re: AFK timer -
Luis- - 02.10.2011
No, I have new AFKTime[MAX_PLAYERS] and forward AFKTimer(playerid).
Re: AFK timer - suhrab_mujeeb - 02.10.2011
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"
Re: AFK timer -
Luis- - 02.10.2011
Yes, that is what I need, I have tried "new seconds++;" and "new seconds += 1;" and had no luck with both.
Re: AFK timer - suhrab_mujeeb - 02.10.2011
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.
Re: AFK timer -
Cypress - 02.10.2011
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?
Re: AFK timer - suhrab_mujeeb - 02.10.2011
Quote:
Originally Posted by Cypress
Why does he need to create a loop?
|
In the new function.