SA-MP Forums Archive
AFK System - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AFK System (/showthread.php?tid=493231)



AFK System - Tadas - 07.02.2014

Hello, can anyone make me a AFK System where admins can tipe /afk and they can see what players is on afk and how long.

Sorry for my bad English


Re: AFK System - BullseyeHawk - 07.02.2014

pawn Код:
// On top of your script
new playerAFKCount[MAX_PLAYERS]; // ->Var

// On OnPlayerUpdate(playerid);
public OnPlayerUpdate(playerid)
{
    playerAFKCount[playerid] = gettime(); //Unix-timestamp.
    return 1;
}

// In your /afk command
new afkSeconds = (((playerAFKCount[id] - gettime()) / 60) / 1000); // This should return you the seconds count of how much a player is afk.
Pretty simple usage, I am not 100% about the afkSeconds. gettime() is a unix-timestamp, I've just converted it as milliseconds, hope I am correct.

If you need me to explain this to you, just tell me.


Re: AFK System - Tadas - 08.02.2014

I got these errors :/
Quote:

C:\Users\Tadas\Desktop\Serveris\gamemodes\naujas.p wn(7) : error 017: undefined symbol "MAX_PLAYERS"
C:\Users\Tadas\Desktop\Serveris\gamemodes\naujas.p wn(7) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\Tadas\Desktop\Serveris\gamemodes\naujas.p wn(737) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Tadas\Desktop\Serveris\gamemodes\naujas.p wn(737) : error 017: undefined symbol "afkSeconds"
C:\Users\Tadas\Desktop\Serveris\gamemodes\naujas.p wn(737) : error 017: undefined symbol "id"
C:\Users\Tadas\Desktop\Serveris\gamemodes\naujas.p wn(737) : fatal error 107: too many error messages on one line