Afk label
#6

Quote:
Originally Posted by Simeon87
View Post
Here's a possible solution using OnPlayerKeyStateChange to detect inactivity.
Note that the SetPlayerChatBubble() expiretime parameter overlaps with the one second timer by 500ms, this is to ensure that the caption remains visible regardless of other factors such as lag.

Code:
#undef MAX_PLAYERS
#define MAX_PLAYERS 32 //The player capacity of your server

#define COLOR_GREEN 0x33AA33AA

new afkTime[MAX_PLAYERS];

forward oneSecond();
public oneSecond()
{
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(IsPlayerConnected(i) && !IsPlayerNPC(i))
		{
			//Display AFK label when the player has been away for at least 30 seconds
			if(afkTime[i] >= 30)
			{
				new caption[32];
				format(caption, sizeof(caption), "AFK - %s seconds.", afkTime[i]);
				SetPlayerChatBubble(i, caption, COLOR_GREEN, 20.0, 1500);
			}
			
			afkTime[i]++;
		}
	}

	return 1;
}

public OnGameModeInit()
{
	SetTimer("oneSecond", 1000, true);
	
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	afkTime[playerid] = 0;

	return 1;
}

public OnPlayerConnect(playerid)
{
	afkTime[playerid] = 0;

	return 1;
}
he want AFK, not inactivity, OnPlayerUpdate return 0 when player is AFK.
whatever, give us the timer.. i can't understand why you send client messages when he is AFK ^_^
Reply


Messages In This Thread
Afk label - by osman2571 - 17.10.2014, 13:15
Re: Afk label - by austin070 - 17.10.2014, 19:23
Re: Afk label - by osman2571 - 17.10.2014, 23:16
Re: Afk label - by osman2571 - 18.10.2014, 11:47
Re: Afk label - by Simeon87 - 18.10.2014, 15:44
Re: Afk label - by 0x41726d79 - 18.10.2014, 16:35
Re: Afk label - by osman2571 - 18.10.2014, 21:02
Re: Afk label - by osman2571 - 18.10.2014, 21:15
Re: Afk label - by Kaperstone - 19.10.2014, 00:01
Re: Afk label - by ThePhenix - 19.10.2014, 00:03

Forum Jump:


Users browsing this thread: 1 Guest(s)