Help with AFK
#1

I'm making and auto-afk checker

I used Redgies and modified it..

Код:
forward CheckAFK();
public CheckAFK()
{
	for(new i = 0; i <= MAX_PLAYERS; i++)
	{
	  if(PPos[i][1] == 0)
	  {
	    GetPlayerPos(i,PPos[i][0],PPos[i][1],PPos[i][2]);
	    return 1;
		}
		new Float:x,Float:y,Float:z;
		GetPlayerPos(i,x,y,z);
		if(x == PPos[i][0] && y == PPos[i][1] && z == PPos[i][2])
		{
		  AFKMins[i]++;
		  if(AFKMins[i] >= AFKTime)
		  {
		    if(AFK[i] == 0)
		    {
		    		AFK[i] = 1;
					TogglePlayerControllable(i,0);
					SetPlayerColor(i,COLOR_GREY);
					oldworld[i] = GetPlayerVirtualWorld(i);
					SetPlayerVirtualWorld(i,10);
					new string[256];
					format(string,sizeof(string),"[ ! ] %s is now in AFK mode!",GetName(i));
					SendClientMessageToAll(COLOR_GREY,string);
				}
			}
		}
	}
	return 1;
}
i enter or leave some place and it doesn't work

Any ideas?

NOTE: /back sets AFKMins to 0 and AFK to 0..
Reply
#2

Virtual World would have nothing to do with being AFK... the check for it is redundant...

Simply checking the XY POS of a player ever 1 sec and comparing it to the next time it loops..

tick +1 if coords match or setvar back to 0 if not match...

from there, you can set whatever var to be your AFK time, 120 secs of no POS change = AFK or whatever..
Reply
#3

Virtual world would make them invisible that's why that's there..

I am already doing the var thing..

checks his XYZ POS in 30 secs, if his pos is the same at the next 30 secs, he becomes AFK
Reply
#4

bump
Reply
#5

Bump #2
Reply
#6

Bump #3 ..

Reply
#7

Код:
forward CheckAFK();
public CheckAFK()
{
	new string[50];
	new Float:x,Float:y,Float:z;
	for(new i,g=GetMaxPlayers(); i < g; i++) if(IsPlayerConnected(i) && !IsPlayerNPC(i))
	{
		GetPlayerPos(i,x,y,z);
		if(x == PPos[i][0] && y == PPos[i][1] && z == PPos[i][2])
		{
		  AFKMins[i]++;
		  if(AFKMins[i] >= AFKTime)
		  {
		    if(AFK[i] == 0)
		    {
		    		AFK[i] = 1;
					TogglePlayerControllable(i,0);
					SetPlayerColor(i,COLOR_GREY);
					oldworld[i] = GetPlayerVirtualWorld(i);
					SetPlayerVirtualWorld(i,10);
					format(string,sizeof(string),"[ ! ] %s is now in AFK mode!",GetName(i));
					SendClientMessageToAll(COLOR_GREY,string);
				}
			}
		}else{
			PPos[i][0] = x;
			PPos[i][1] = y;
			PPos[i][2] = z;
		}
	}
	return 1;
}
Reply
#8

Thanks it works
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)