[Include] roAFK - Efficient AFK System
#1

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
Note: TogglePlayerAFK doesn't support any value like '0' and '1' it only supports bool (true/false)

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
     }
}
How to use public callback OnPlayerAFK (now known as OnPlayerAFKKick)?:

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);
}
This is how to use OnPlayerAFK (now known as OnPlayerAFKKick) in v1.1

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);
}
how to use public callback OnPlayerBack?:

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;
}
How to create /afk with roAFK?:

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;
}
this is how to make afk in v1.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;
}
Note: AFK Creating is now more easier than normal AFK Systems by using OnPlayerBack and custom TogglePlayerAFK

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!
Reply


Messages In This Thread
roAFK - Efficient AFK System (v1.1 is released) - by RollTi - 26.04.2012, 03:02
Re: roAFK - Efficient AFK System - by Derek_Westbrook - 26.04.2012, 03:07
Re: roAFK - Efficient AFK System - by RollTi - 26.04.2012, 03:10
Re: roAFK - Efficient AFK System - by Ballu Miaa - 26.04.2012, 03:45
Re: roAFK - Efficient AFK System - by RollTi - 26.04.2012, 04:21
Re: roAFK - Efficient AFK System - by Jonny5 - 26.04.2012, 04:31
Re: roAFK - Efficient AFK System - by Phyrunx - 26.04.2012, 14:07
Re: roAFK - Efficient AFK System - by TheArcher - 26.04.2012, 14:12
Re: roAFK - Efficient AFK System - by RollTi - 27.04.2012, 00:41
Re: roAFK - Efficient AFK System - by RollTi - 27.04.2012, 02:56
Respuesta: roAFK - Efficient AFK System - by Francis. - 27.04.2012, 03:07
Re: Respuesta: roAFK - Efficient AFK System - by RollTi - 27.04.2012, 03:09
Re: roAFK - Efficient AFK System - by Zaito - 27.04.2012, 08:39
Re: roAFK - Efficient AFK System - by Dude_Lebowski - 27.04.2012, 09:07
Re: roAFK - Efficient AFK System - by RollTi - 27.04.2012, 11:58
Re: roAFK - Efficient AFK System (v1.1 is released) - by iTorran - 27.04.2012, 12:03
Re: roAFK - Efficient AFK System - by RollTi - 27.04.2012, 12:07

Forum Jump:


Users browsing this thread: 2 Guest(s)