Innactive players - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Innactive players (
/showthread.php?tid=579258)
Innactive players -
kalanerik99 - 25.06.2015
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$$)
Re: Innactive players -
Alex Magaсa - 25.06.2015
https://sampforum.blast.hk/showthread.php?tid=281590
https://sampforum.blast.hk/showthread.php?tid=479616
Re: Innactive players -
kalanerik99 - 25.06.2015
Any other posibility?
Re: Innactive players -
Jefff - 25.06.2015
pawn Код:
new PlayaTick[MAX_PLAYERS];
bool:IsPlayerAFK(playerid)
{
return ( (GetTickCount() - PlayaTick[playerid] ) > 650);
}
public OnPlayerUpdate(playerid)
{
PlayaTick[playerid] = GetTickCount();
return 1;
}
Re: Innactive players -
kalanerik99 - 25.06.2015
How this should work what doest it do
I made this but nothing pls help
THIS IS REALLY SIMPLE DESIGN (2 SECONDS OF MAKING =) )
PHP код:
new PlayaTick[MAX_PLAYERS];
bool:IsPlayerAFK(playerid)
{
return ( (GetTickCount() - PlayaTick[playerid] ) > 650);
}
public OnPlayerUpdate(playerid)
{
new string[512],name[512];
PlayaTick[playerid] = GetTickCount();
foreach(new i : Player)
{
if(IsPlayerAFK(i))
{
GetPlayerName(i,name,sizeof(name));
format(string,sizeof(string),"%s is inactive",name);
SendClientMessageToAll(-1,string);
}
}
return 1;
}
Re: Innactive players -
Jefff - 25.06.2015
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;
}
Re: Innactive players -
kalanerik99 - 25.06.2015
How would you do it without timer
Like me
Re: Innactive players -
Jefff - 25.06.2015
You can't show info without timer
Re: Innactive players -
kalanerik99 - 25.06.2015
Why not?