format(string, sizeof(string), ""SERVERBLUE"[ AFK ]\n"WHITE"Time: %d:%d:%d", hours, minutes, seconds);
AFKLabel[i] = CreateDynamic3DTextLabel(string, 0x1D9F00AA, X, Y, Z+1, 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
forward AFKtimer();
public AFKtimer()
{
foreach(new i: Player)
{
new Float:X, Float:Y, Float:Z, string[90], hours = 0, minutes = 0, seconds = 0;
GetPlayerPos(i, X, Y, Z);
seconds++;
if(seconds == 60)
{
minutes ++;
seconds = 0;
}
else if(minutes == 60)
{
hours ++;
minutes = 0;
seconds = 0;
}
format(string, sizeof(string), ""SERVERBLUE"[ AFK ]\n"WHITE"Time: %d", seconds);
AFKLabel[i] = CreateDynamic3DTextLabel(string, 0x1D9F00AA, X, Y, Z+1, 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 20.0);
return 1;
}
return 1;
}
|
I don't get what are you doing there.
hours, minutes and seconds are initialized with zero, then you higher seconds by one. It will always be that since the variables are local and will be initialized with zero for every player, everytime. Make those global, or use GetTickCount() to simply calculate the time between the moment the player went AFK and now. |

|
Dang I just realised that....haahahahaha I am stupid :d Thank you for pointing that out m8
![]() Repped |

|
No problem, happens sometimes
![]() Try the timestamp method, it's way more precise and in my opinion even easier. |