how to not check player afk
#1

Made a simple AFK detection code, that everytime the players will be detected afk in a total of few minutes, it will get him into a interior with a text "type /lobby everytime you want to go afk blablabal", but once on /lobby how to make the AFK not detect there?

Код:
forward AFKCheck();
public AFKCheck()
{
  new Float:Pos[3]; // creating an array variable of 3 values whose datatype is Float.
  for(new i = 0; i < MAX_PLAYERS; i++) // Looping through the players.
  {
     GetPlayerPos(i,Pos[0],Pos[1],Pos[2]); // Gets the player position and saves into their variables.
     if(IsPlayerInRangeOfPoint(i,2,Pos[0],Pos[1],Pos[2])) // If player is around the position (if player is at the same place)
     {
        AFK[i]++; // Increment the AFK variable (for every second if player is at same location, increase the AFK variable by 1)
     }
     if(AFK[i] == 60) // If it has been a minute for the player being at the same place
     {
		 SetPlayerPos(i, -975.975708,1060.983032,1345.671875);
		 SetPlayerInterior(i, 10);
		 SetPlayerVirtualWorld(i, 10);
		 SetPlayerHealth(i, 9999);
		 ResetPlayerWeapons(i);
		 SendClientMessage(i, -1, "{EFB509}(INFO) Looks like you was afk.. next time type /lobby everytime you go afk.");
      }
  }
  return 1;
}
Код:
CMD:lobby(playerid,params[])
{
  new Float:health;
  new interiorID = GetPlayerInterior(playerid);
  GetPlayerHealth(playerid, health);
  if(health  > 90)
  {
	 SetPlayerPos(playerid, -975.975708,1060.983032,1345.671875);
	 SetPlayerInterior(playerid,10);
	 SetPlayerVirtualWorld(playerid,10);
	 SetPlayerHealth(playerid, 9999);
	 ResetPlayerWeapons(playerid);
	 SendClientMessage(playerid, -1, "{EFB509}(INFO) You have teleported to the lobby! In order to go back use /back.");
  }
  else
  {
    if(interiorID == 0) return SendClientMessage(playerid, -1, "{c3c3c3}(INFO) Atleast 90hp is required in order to go to lobby.");
  }
  {
    if(interiorID == 10) return SendClientMessage(playerid, -1, "{c3c3c3}You are already in the lobby! Use /back to return playing.");
  }
  return 1;
}
Reply
#2

Set a bool: check true once player is afk and false once he's out or use IsPlayerInRangeOfPoint
Reply
#3

Ohh right! , thanks solved XD
Reply
#4

IsPlayerInRangeOfPoint , easiest way.
Reply
#5

Or if you are using Incognitos streamer, you could use OnPlayerEnterDynamicArea/OnPlayerExitDynamicArea, or IsPlayerInDynamicArea.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)