[HELP]AFK Checker
#1

Код:
//AFK
new Float:afkx, Float:afky, Float:afkz;
new Float:afkxdopo, Float:afkydopo, Float:afkzdopo;
new afkpos;
new afkpos1;
new coloreini;
forward ControlloAFK();
forward ControlloAFK1(i);
new IsAfk[MAX_PLAYERS] = 0;
new originame[MAX_PLAYERS][24];
Код:
stock PlayerPosPrima(playerid) {
	GetPlayerPos(playerid, afkx, afky, afkz);
	return afkpos;
}

stock PlayerPosDopo(playerid) {
	GetPlayerPos(playerid, afkxdopo, afkydopo, afkzdopo);
	return afkpos1;
}
Код:
public ControlloAFK()
{
  	for(new i = 0; i < MAX_PLAYERS; i++)
  {
		if(IsPlayerConnected(i))
		{
		  if(IsAfk[i] != 0){
			afkpos = PlayerPosPrima(i);
			SetTimerEx("ControlloAFK1", 60000, false, "i",i);
			} else {
			afkpos = PlayerPosPrima(i);
			SetTimerEx("ControlloAFK1", 15000, false, "i", i);
			}
		}
	}
return 1;
}

public ControlloAFK1(i)
{
	coloreini = GetPlayerColor(i);
	afkpos1 = PlayerPosDopo(i);
	new string[128];
	if(afkpos == afkpos1 && IsAfk[i] != 1)
	{
		SetPlayerColor(i, COLOR_GREEN);
		IsAfk[i] = 1;
		SetTimer("ControlloAFK", 3000, false);
		format(string, sizeof(string), "%s и AFK (Away From KeyBoard)", PlayerName(i));
		SendClientMessageToAll(COLOR_GREEN,string);
		new name[MAX_PLAYER_NAME];
    format(name,MAX_PLAYER_NAME,"[AFK]%s",PlayerName(i));
		SetPlayerName(i,name);

 	} else if(afkpos != afkpos1 && IsAfk[i] == 1)
	{
		SetPlayerColor(i, coloreini);
		IsAfk[i] = 0;
		SetTimer("ControlloAFK", 3000, false);
		format(string, sizeof(string), "%s и tornato", PlayerName(i));
		SendClientMessageToAll(COLOR_GREEN,string);
		SetPlayerName(i,originame[i]);
	} else if(afkpos != afkpos1 && IsAfk[i] != 1)
	{
		IsAfk[i] = 0;
		SetTimer("ControlloAFK", 3000, false);
	} else SetTimer("ControlloAFK", 3000, false);

return 1;
}
It make Everyone AFK.. Any help?
Reply
#2

little up
Reply
#3

It may be an idea to edit MAX_PLAYERS to the max server slots you have.

Код:
#include <a_samp>

#define AFK_TIME 30000

new bool:respond[MAX_PLAYERS];
forward CheckAFK();

public OnGameModeInit()
{
	SetTimer("CheckAFK", AFK_TIME, 1);
	return 1;
}

public CheckAFK(){
	new i = -1;
	while(++i < MAX_PLAYERS){
	  if(!IsPlayerConnected(i)) continue;
	  if(respond[i] == false){ // Keel them for being AFK
	    SendClientMessage(i, 0xFFFFFFFF, "You are away from keyboard!");
	    printf("Playerid %i is AFK", i);
	  }
	  else respond[i] = false;
	}
}

public OnPlayerUpdate(playerid)
{
	if(respond[playerid] == false){
	  respond[playerid] = true;
	}
	return 1;
}
Replace this code with the actions you want to take. So if you want to kick them. Use Kick(i);
Код:
SendClientMessage(i, 0xFFFFFFFF, "You are away from keyboard!");
printf("Playerid %i is AFK", i);
Reply
#4

And when player is back?
Reply
#5

Quote:
Originally Posted by [IF
MavericK ]
And when player is back?
It will trigger OnPlayerUpdate then.
Reply
#6

Use this: http://forum.sa-mp.com/index.php?topic=79463.0

SEARCH!
Reply
#7

Quote:
Originally Posted by [SU
I'm trying to do it automatically, without cmds
Reply
#8

that's good, i'm going to try it
Reply
#9

i've errors...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)