SA-MP Forums Archive
Afk label - 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 label (/showthread.php?tid=542154)



Afk label - osman2571 - 17.10.2014

how to make afk time.
Default is the time in scm - SendClientMessage and how to make it in 3dtextlabel


Default:

Code:
if(IsPlayerConnected(i))
			{
			    if(AFK[i] == 1)
			    {
			        GetPlayerName(i, sendername, sizeof(sendername));
					new Float:time = AFKTime[i];
					format(string, 256, "{FF6347}%s (%d) {FFFFFF}| Afk vrijeme:{FF6347}%.1fmin", sendername, i,time);
					SCM(playerid, COLOR_WHITE, string);
				}
			}
Label:

Code:
AFK[i] = 1;
						AfkLabel[i] = Create3DTextLabel("[AFK - Nisam u igrici!]",0xFF000099,0,0,0,50,-1,1);
						Attach3DTextLabelToPlayer(AfkLabel[i], i, 0,0,0);
I try to make that system like this but don't work

Code:
AfkLabel[i] = Create3DTextLabel("[AFK - Nisam u igrici %.1fmin!]",0xFF000099,0,0,0,50,-1,1,time);



Re: Afk label - austin070 - 17.10.2014

Why is it in a loop? Where is this function?


Re: Afk label - osman2571 - 17.10.2014

This is Timer:AfkDetect in loop system


Re: Afk label - osman2571 - 18.10.2014

BUMP


Re: Afk label - Simeon87 - 18.10.2014

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;
}



Re: Afk label - 0x41726d79 - 18.10.2014

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 ^_^


Re: Afk label - osman2571 - 18.10.2014

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;
}
Not counting my seconds, rather than minutes -.-
How to make it count first minute and then a second?


Re: Afk label - osman2571 - 18.10.2014

Quote:
Originally Posted by 0x41726d79
View Post
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 ^_^
I want to do when afk that he counts down how many afk
But in my system counts down the time to chat not to label

PS:Sorry about my bad English :P


Re: Afk label - Kaperstone - 19.10.2014

Quote:
Originally Posted by osman2571
View Post
IBut in my system counts down the time to chat not to label
EDIT: Missread the first post, Simon already answered.
Quote:
Originally Posted by osman2571
View Post
Not counting my seconds, rather than minutes -.-
How to make it count first minute and then a second?
60 seconds in a minute, devide the seconds by 60 and then round(floor) it .
Then you will get the minutes.


Re: Afk label - ThePhenix - 19.10.2014

Use this instead:
https://sampwiki.blast.hk/wiki/SetPlayerChatBubble