Posts: 473
Threads: 86
Joined: Mar 2012
Reputation:
0
Hello
I have one question
How to get if player is in inactive state (look attachment)
Shall I do it:
-with timers and if player pos. is the same for like 1.5 mins (BAD WAY)
-or if player press (ESC....)button?
-IS THERE ANY FUNCTION TO GET IF PLAYER IS IN THAT STATE (look attachment)
Regards kalanerik99 (DARKBO$$)
Posts: 2,593
Threads: 34
Joined: Dec 2007
pawn Код:
new PlayaTick[MAX_PLAYERS];
bool:IsPlayerAFK(playerid)
{
return ( (GetTickCount() - PlayaTick[playerid] ) > 650);
}
public OnPlayerUpdate(playerid)
{
PlayaTick[playerid] = GetTickCount();
return 1;
}
Posts: 2,593
Threads: 34
Joined: Dec 2007
pawn Код:
new PlayaTick[MAX_PLAYERS], bool:PlayerAFK[MAX_PLAYERS char];
// OnGameModeInit
SetTimer("ScanPlayers",1000,true);
// OnPlayerConnect
PlayerAFK{playerid} = false;
// somewhere in GameMode
forward ScanPlayers();
public ScanPlayers()
{
static string[40], name[MAX_PLAYER_NAME], Tick;
Tick = GetTickCount();
foreach(new i : Player)
{
if(((Tick - PlayaTick[i)) > 750))
{
if(!PlayerAFK{i})
{
PlayerAFK{i} = true;
GetPlayerName(i,name,sizeof(name));
format(string,sizeof(string),"%s is inactive",name);
SendClientMessageToAll(-1,string);
}
}
else
{
if(PlayerAFK{i})
{
PlayerAFK{i} = false; // player is back from AFK
}
}
}
}
public OnPlayerUpdate(playerid)
{
PlayaTick[playerid] = GetTickCount();
return 1;
}
Posts: 2,593
Threads: 34
Joined: Dec 2007
You can't show info without timer