28.11.2010, 13:09
Yes, but don't use GetTickCount for that, you can increment the variable in the timer.
fast and easy:
fast and easy:
Код:
#undef MAX_PLAYERS #define MAX_PLAYERS 30 new afk[MAX_PLAYERS]; public OnGameModeInit() { // Don't use these lines if it's a filterscript SetGameModeText("Blank Script"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); SetTimer("AFKTimer", 1000, 1); return 1; } forward AFKTimer(); public AFKTimer() { for (new i = 0; i < MAX_PLAYERS; i++) { if (IsPlayerConnected(i)) { afk[i]++; if (afk[i] % 30 == 0) { new msg[60]; format(msg, 59, "player %d is afk for %d seconds now!", i, afk[i]); SendClientMessageToAll(0xFFFFFF00, msg); } } } } public OnPlayerUpdate(playerid) { afk[playerid] = 0; return 1; }