afk check doesnt work
#1

OnPlayerConnect

PHP код:
SetTimerEx("AFKCheck"50001"i"playerid); 
PHP код:
forward AFKCheck(playerid);
public 
AFKCheck(playerid)
{
  new 
Float:Pos[3]; 
  for(new 
0MAX_PLAYERSi++)
  {
     
GetPlayerPos(i,Pos[0],Pos[1],Pos[2]);
     if(
IsPlayerInRangeOfPoint(i,2,Pos[0],Pos[1],Pos[2])) 
     {
        
AFK[i]++; 
     }
     if(
AFK[i] == 60)
     {
        
AFK[i] = 0;
        
Lounge[i] = true;
        
SetPlayerPos(i, -794.806396,497.738037,1376.195312);
        
SetPlayerInterior(i1);
        
SetPlayerVirtualWorld(i,10);
        
IsPlayerInLobby[i] = 1;
        
SetPlayerHealth(i99999);
        
ResetPlayerWeapons(i);
        new 
string[250];
        
format(stringsizeof(string), "_AFK_%s"PlayerName[i]);
        
SetPlayerName(istring);
        
SetPlayerColor(iCOLOR_GREY);
      }
  }
  return 
1;

I joined a test sv with my friends, he goes afk, but instead changing his nickanem to _AFK_clown, i get it changed to myself instead, there's someting wrong with the "id's" cant figure out.
Reply
#2

Could you show the AFK code too?
Reply
#3

It's just a variable that increases the count , and once it reaches 60, it will detect the player as being "afk".

PHP код:
new AFK[MAX_PLAYERS]; 
The system works, but when theres 2 players, it confuses the player id of who is going afk and who not. And so it puts all together.
Reply
#4

Well first that check is too messy it'll never work for several reasons which i don't have time to state atm,

Although here's something i made really quick: CLICK HERE

It gives these to control with:

Код:
/*Functions:
__________*/
bool:IsPlayerPaused(playerid); //If the player pressed the Esc button
bool:IsPlayerAFK(playerid); //If the player isn't moving

/*Callbacks:
__________*/
public OnPlayerPause(playerid) //Once a player presses the Esc button
public OnPlayerResume(playerid) //Once a player returns from pausing

public OnPlayerAFK(playerid) //Once a player stops moving for about 55-65 seconds
public OnPlayerReturn(playerid) //Once a player starts moving again
It's an include so yeah just include it in your script using:
Код:
#include <rAfk_Checker>
Reply
#5

Thanks for answer, will try this
Reply
#6

1. You already set playerid param why would you loop again through all players?
2. You must get the player position for the first time at spawn

PHP код:
public OnPlayerSpawn(playerid)
{
    
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); 
    return 
1;
}
forward AFKCheck(playerid); 
public 
AFKCheck(playerid

  new 
Float:Pos[3];  
     if(
IsPlayerInRangeOfPoint(playerid,2,Pos[0],Pos[1],Pos[2]))  
     { 
        
AFK[playerid]++;  
     } 
     else 
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]); 
     if(
AFK[playerid] == 60
     { 
        
AFK[playerid] = 0
        
Lounge[playerid] = true
        
SetPlayerPos(playerid, -794.806396,497.738037,1376.195312); 
        
SetPlayerInterior(playerid1); 
        
SetPlayerVirtualWorld(playerid,10); 
        
IsPlayerInLobby[playerid] = 1
        
SetPlayerHealth(playerid99999); 
        
ResetPlayerWeapons(playerid); 
        new 
string[250]; 
        
format(stringsizeof(string), "_AFK_%s"PlayerName[playerid]); 
        
SetPlayerName(playeridstring); 
        
SetPlayerColor(playeridCOLOR_GREY); 
      }  
  return 
1

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)