How To Create a Auto Afk system? - 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: How To Create a Auto Afk system? (
/showthread.php?tid=338834)
How To Create a Auto Afk system? -
Torus - 01.05.2012
Guys I have seen many servers using auto afk system and i always try / wonder how they made it.I tryed to make one but it was not working atlast i gave up and i wanna ask here how to make it?. If Some one helps me it will +1 rep and i will be very thkfull to him.
sorry i forgot to mention that without any cmd i mean when the player press esc then he gets afk and when hes back from afk and moves then hes back
Re: How To Create a Auto Afk system? -
Faisal_khan - 01.05.2012
Here have it:
pawn Код:
if (strcmp("/back", cmdtext, true, 4) == 0)
{
TogglePlayerControllable(playerid,1);
SendClientMessage(playerid,COLOR_PINK,"You are not AFK Anymore !");
return 1;
}
if (strcmp("/afk", cmdtext, true, 3) == 0)
{
TogglePlayerControllable(playerid,0);
SendClientMessage(playerid,COLOR_PINK,"You are now AFK!");
return 1;
}
Re: How To Create a Auto Afk system? -
Torus - 01.05.2012
Quote:
Originally Posted by Faisal_khan
Here have it:
pawn Код:
if (strcmp("/back", cmdtext, true, 4) == 0) { TogglePlayerControllable(playerid,1); SendClientMessage(playerid,COLOR_PINK,"You are not AFK Anymore !"); return 1; } if (strcmp("/afk", cmdtext, true, 3) == 0) { TogglePlayerControllable(playerid,0); SendClientMessage(playerid,COLOR_PINK,"You are now AFK!"); return 1; }
|
No dude i meant auto afk without any commands when the player press esc that time i meant
Re: How To Create a Auto Afk system? -
Faisal_khan - 01.05.2012
pawn Код:
new AFK[MAX_PLAYERS];
// ...
public OnGameModeInit()
{
// Run a timer here
SetTimer("CheckAFK", 1000, true);
}
// ...
public OnPlayerUpdate(playerid)
{
// If the player just came back from being afk, the AFK variable is most likely more than 3/5 (vary this based on your gamemode and experience)
if(AFK[playerid] > 3)
{
// This player just came back from being AFK
}
AFK[playerid] = 0;
}
// ...
forward CheckAFK();
public CheckAFK()
{
// Suggestions for loop: either use foreach or at least define MAX_PLAYERS to your server's server.cfg amount!
for(new i = 0; i != MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
AFK[i] ++;
if(AFK[i] == 3)
{
// The player most likely just went AFK!
}
}
}
Re: How To Create a Auto Afk system? -
Torus - 01.05.2012
Thanks REPPED!
Re: How To Create a Auto Afk system? -
Faisal_khan - 02.05.2012
Quote:
Originally Posted by Torus
Thanks REPPED!
|
Welcome bro!
Re: How To Create a Auto Afk system? -
Gamer_007 - 06.07.2012
thanks faisal
Re: How To Create a Auto Afk system? -
Faisal_khan - 08.07.2012
Quote:
Originally Posted by Gamer_007
thanks faisal
|
Np DUDE!