26.04.2012, 03:02
(
Последний раз редактировалось RollTi; 27.04.2012 в 12:08.
Причина: v1.1 released
)
roAFK - Efficient AFK System
Made by RollTi
Note: Version 1.1 is released!__________________________
Version: v1.1
Author: RollTi
Very Special Thanks to:
- Meta
- iPLEOMAX
- and other person who help me
Introduction:
roAFK is efficient afk system yet (or maybe Torran's AFK inc?), when the TogglePlayerAFK is enable (true) the OnPlayerAFK (now known as OnPlayerAFKKick) function is called after 5 minutes. Yet roAFK is the second include AFK System in Filterscript and Includes section.
Updates:
v 1.0 roAFK:
- First Release
v1.1 roAFK:
- OnPlayerAFK public callback has rename to OnPlayerAFKKick
- OnPlayerBack public callback added (Note: This callback is called when TogglePlayerAFK is setting to false)
- TogglePlayerAFK has new few things that v1.0 roAFK doesn't have:
• You will go to a room when you go to AFK
• will disarm your weapon (when you afk mode off your weapon will give to you back)
• When you AFK mode off you will go back in your last position and current interior/virtual world before /afk
• roAFK has now client message so you don't need to add a code for 'RollTi are away from his keyboard
How to use it:
How to use TogglePlayerAFK?:
its easy like TogglePlayerControllable you can do
pawn Код:
TogglePlayerAFK(playerid, true); //sets player to afk
or
TogglePlayerAFK(playerid, false); //sets player to afk mode off
TogglePlayerAFK has a timer inside using SetTimerEx, with SetTimerEx public callback OnPlayerAFK (now known as OnPlayerAFKKick) will be called after 5 minutes.
Other Notes: it is now upgraded more easy to use than in v1.0
How to use GetPlayerAFKToggle for /afk command?:
its easy like other function like GetPlayerSpecialAction it also includes GetPlayerAFKToggle, it is useful for /afk
pawn Код:
switch(GetPlayerAFKToggle(playerid))
{
case false: //checks if player is not afk
{
//codes
}
case true: //checks if player is afk
{
//codes
}
}
like i mentioned above OnPlayerAFK (now known as OnPlayerAFKKick) is called after 5 mins (it is only called when someone uses TogglePlayerAFK)
This is example how i use it
This is how to use OnPlayerAFK on v1.0
pawn Код:
public OnPlayerAFK(playerid)
{
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(str, 128, "%s(%d) has been kicked for being AFK - 5 minutes!", name, playerid);
SendClientMessageToAll(-1, str);
print("5 minutes has past!"); //sorry this is debug i forgot to remove it
KillTimer(AFKTimer[playerid]);
return Kick(playerid);
}
pawn Код:
public OnPlayerAFKKick(playerid)
{
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "%s has been kicked for AFKing for 5 minutes", name);
SendClientMessageToAll(-1, str);
SendClientMessage(playerid, -1, "You have been kicked for AFKing for 5 minutes!");
return Kick(playerid);
}
Now creating AFK with roAFK is now more easier than in v1.0.
with new custom upgrade TogglePlayerAFK, OnPlayerBack is now called
OnPlayerBack is called when TogglePlayerAFK is setting to false
This is example how to use it
pawn Код:
public OnPlayerBack(playerid)
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
PlayerPlaySound(playerid, 1085, 0, 0, 0);
format(string, sizeof(string), "%s are Back from his Keyboard!", name);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are back from your keyboard!");
return 1;
}
here hows i do it in zcmd.
You can also use TogglePlayerAFK in strcmp and in other command processor
This is the way how to make afk in v1.0
pawn Код:
CMD:afk(playerid, params[])
{
new string[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
switch(GetPlayerAFKToggle(playerid))
{
case false:
{
TogglePlayerAFK(playerid, true);
format(string, 128, "%s(%d) are Away from his Keyboard!", name, playerid);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are away from your keyboard!");
}
case true:
{
TogglePlayerAFK(playerid, false);
format(string, 128, "%s(%d) are Back from his Keyboard!", name, playerid);
SendClientMessageToAll(-1, string);
SendClientMessage(playerid, -1, "You are back from your keyboard!");
}
}
return 1;
}
pawn Код:
CMD:afk(playerid, params[])
{
switch(GetPlayerAFKToggle(playerid))
{
case false:
{
TogglePlayerAFK(playerid, true);
PlayerPlaySound(playerid, 1085, 0, 0, 0);
}
case true:
{
TogglePlayerAFK(playerid, false);
}
}
return 1;
}
You can also use if statement but i prefer switch because its easier.
Errors/Warnings (Bugs):
I have found one while creating my /afklist
when i use if(GetPlayerAFKToggle(playerid) == true) i get a warning tag mismatch
please all users who use roAFK use switch when you going to use if statement in GetPlayerAFKToggle
Total Warnings/Errors/Bugs: 1
Report/PM if you find one
Download:
Don't forget to download YSI: YSI by ******
roAFK - Efficient AFK System v1.0 (Pastebin)
roAFK - Efficient AFK System v1.0 (Mediafire)
roAFK - Efficient AFK System v1.1 (Mediafire)
______________________________
Credits:
RollTi (me) - Scripting
****** - YSI\y_hooks
Meta - Helping in GetPlayerAFKToggle
iPLEOMAX - Helping in GetPlayerAFKToggle
and other person that i didn't mentioned
Have fun creating your own /afk supports with Anti-AFK 5 minutes!
Have suggestion for next update post here!