02.10.2011, 14:22
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.
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;
}