[AFK]Auto-AFK System -
Xtreme Brotherz - 28.09.2012
[AFK]AUTO-AFK SYSTEM
Hai Guys!.. I may not be familiar as this is my first filterscript. This FilterScript auto-detects player's AFK status to switch between the states.
Inserts these lines in your gamemode or filterscript at respective places.
INCLUDES
DEFINES
pawn Code:
#define AFK_TIMER 1
//Timer for detecting whether player in AFK
ENUMS
pawn Code:
enum Info_Afk{Timer, bool: Inactive};
NEWS
pawn Code:
new Player[MAX_PLAYERS][Info_Afk];
new afkname[29],string[128]; //Default name size is 24 but this needs 5 more
FORWARDS
pawn Code:
forward Detect_Afk(playerid);
ON PLAYER CONNECT
pawn Code:
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid,afkname,sizeof(afkname));
if(strfind(afkname,"[AFK]", true)!=-1)
{
SendClientMessage(playerid,-1,"[ERROR:] Invalid nickname. You have been kicked.");
Kick(playerid);
}
return 1;
}
ON PLAYER SPAWN
pawn Code:
public OnPlayerSpawn(playerid)
{
Player[playerid][Timer]=SetTimerEx("Detect_Afk", AFK_TIMER, false, "d", playerid);
return 1;
}
PUBLICS
pawn Code:
public Detect_Afk(playerid)
{
GetPlayerName(playerid, afkname, sizeof(afkname));
format(string,sizeof(string),"[AFK]%s",afkname);
SetPlayerName(playerid, string);
Player[playerid][Inactive] = true;
format(string,sizeof(string),"%s {FFFFFF} is AFK",afkname);
SendClientMessageToAll(-1,string);
TogglePlayerControllable(playerid,0);
return 1;
}
PLAYER KEY STATE CHANGE
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
Afk_Return(playerid);
return 1;
}
ON PLAYER TEXT
pawn Code:
public OnPlayerText(playerid,text[])
{
Afk_Return(playerid);
return 1;
}
STOCKS
pawn Code:
stock Afk_Return(playerid)
{
KillTimer(Player[playerid][Timer]);
Player[playerid][Timer]=SetTimerEx("Detect_Afk", AFK_TIMER, false, "d", playerid);
if(Player[playerid][Inactive])
{
format(string,sizeof(string),"%s {FFFFFF}is back from AFK state",afkname);
SendClientMessageToAll(-1,string);
Player[playerid][Inactive]=false;
TogglePlayerControllable(playerid,1);
GetPlayerName(playerid,afkname,sizeof(afkname));
if(strfind(afkname,"[AFK]", true)!=-1)
{
strdel(afkname,0,5);
SetPlayerName(playerid,afkname);
}
}
}
ON OLAYER DISCONNECT
pawn Code:
public OnPlayerDisconnect(playerid)
{
KillTimer(Player[playerid][Timer]);
Player[playerid][Inactive]=false;
GetPlayerName(playerid,afkname,sizeof(afkname));
if(strfind(afkname,"[AFK]", true)!=-1)
{
strdel(afkname,0,5);
SetPlayerName(playerid,afkname);
}
return 1;
}
Thank you!
+Rep me if u found it useful
[NOTE] : You may use it without credits by giving a +rep
Re: [AFK]Auto-AFK System -
-Rafinha_FusioN- - 28.09.2012
Fico Dahora Lek
Re: [AFK]Auto-AFK System -
jpeg - 28.09.2012
not bad..
Re: [AFK]Auto-AFK System -
RaZzZzoR - 28.09.2012
That's more a tutorial
Good job.
Re: [AFK]Auto-AFK System -
Xtreme Brotherz - 28.09.2012
Thnnx and +rep if its good
Re: [AFK]Auto-AFK System -
KingHual - 28.09.2012
Quote:
Originally Posted by Xtreme Brotherz
Thnnx and +rep if its good
|
No. Just no.
Re: [AFK]Auto-AFK System -
Xtreme Brotherz - 28.09.2012
Quote:
Originally Posted by king_hual
No. Just no.
|
cant stop laughing
gud joke anyway
Re: [AFK]Auto-AFK System -
KINGINA - 28.09.2012
Nice!
Re: [AFK]Auto-AFK System -
NoahF - 28.09.2012
Very cool idea! It can be pretty useful for just about any server, another nice release. Keep em' comin'!
Re: [AFK]Auto-AFK System -
KingHual - 29.09.2012
Quote:
Originally Posted by Xtreme Brotherz
I may not be familiar as this is my first filterscript.
|
Quote:
Originally Posted by NoahF
another nice release. Keep em' comin'!
|
What.