Check AFK Player
#1

With what function you can check to see if the player is AFK?
Checking the position is not suitable
Reply
#2

In case checking for /afklist
PHP Code:
new AFK[MAX_PLAYERS];
for(new 
0iMAX_PLAYERSi++)
    {
        if(
IsPlayerConnected(i))
        {
            if(
AFK[i] == 1
in-case like not allowind to chat or already afk
PHP Code:
new AFK [MAX_PLAYERS];
if(
AFK[playerid] == 1)
    {
        return 
GameTextForPlayer(playerid"You are already in AFK. Use /back",3000,3);
    } 
Reply
#3

This is not an option, the script itself should determine the player is in the AFC or not
Reply
#4

Code:
forward AFK();
new afk[MAX_PLAYERS];

public AFK()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        afk[i]++;
    }
}

public OnGameModeInit()
{
     SetTimer("AFK", 1000, true);
}

public OnPlayerUpdate(playerid)
{
    afk[playerid] = 0;
}

CMD: afk(playerid)
{
	new name[28];
	new string[128]
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(afk[i] = 3;
		{
			format(string, sizeof(string), "%s is AFK.",GetPlayerName(i, name, sizeof(name));
			SendClientMessage(playerid, -1, string);
		}
	}
	return 1;
}
Your welcome
Reply
#5

See if the player returns 0 because when you are 'Escape' (in the menu or main screen) away from the game, the updates are not sent. (Am I right, can this be used?)
You can use this in mixture with position checking to create a powerful AFK check-er.
Reply
#6

jeez... Jujst look up for the include OnPlayerPause on googpe. it has two functions, when player pauses and when he gets back. start a timer that check how long a player been afk for
Reply
#7

if you want try this https://sampforum.blast.hk/showthread.php?tid=418384
Reply
#8

You can use OnPlayerPause inc.
Reply
#9

Now that we have the little 'hourglass' icon depicting the player pause, I was expecting an OnPlayerPause callback/IsPlayerPaused function too! Alas.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)