[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
#2

Nice!REP 1+ for you!This is useful to all servers.
Reply
#3

Quote:
Originally Posted by Derek_Westbrook
Посмотреть сообщение
Nice!REP 1+ for you!This is useful to all servers.
Thx

Anyway

the part

pawn Код:
print("5 minutes has past!");
is debug i forgot to remove it when i was going to release it
Reply
#4

Uhh you released it Great work RollTi xD. Already repped ya. Cant do it anymore lolx.
Reply
#5

Thanks everyone

by the way important news!

I found out that if you use if statement in GetPlayerAFKToggle you will get warning tag mismatch
so use switch instead of if statement

going to post this in the main post
Reply
#6

nice work!
useful for many servers.
Reply
#7

Good Job!!!!
Reply
#8

Congrats. for the script but the 50th AFK system is going to be annoying. BTW at least i appreciate the new features on this script
Reply
#9

Quote:
Originally Posted by Phyrunx
Посмотреть сообщение
Good Job!!!!
Thank you

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
Congrats. for the script but the 50th AFK system is going to be annoying. BTW at least i appreciate the new features on this script
Somebody is about to release a AFK Include like mine.

Anyway current updating and adding something new in v1.1
Reply
#10

Current updates for next version:

- OnPlayerAFK Public callback has rename to OnPlayerAFKKick
- OnPlayerBack Public callback has added for TogglePlayerAFK - false
- When TogglePlayerAFK - false is called OnPlayerBack public call back is called
- Added roAFK Client, roAFK Client are called when TogglePlayerAFK is true

Post some suggestions here
Reply
#11

What's the difference between this script and the others?
I don't see the point.
Reply
#12

Quote:
Originally Posted by Francis.
Посмотреть сообщение
What's the difference between this script and the others?
I don't see the point.
I'm trying my best to add some features that other AFK System has never done before
Thats why i'm asking for suggestion then now you telling me

Quote:
Originally Posted by Francis.
Посмотреть сообщение
What's the difference between this script and the others?
I don't see the point.


i see the point right now...
Reply
#13

nice, gotta use it in my GM script , Great work and keep up the good work RollTi +rep
Reply
#14

very usefull and looks good Thanks !
Reply
#15

v1.1 of roAFK has been now released

New Updates:

- 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
Reply
#16

Quote:
Originally Posted by RollTi
Посмотреть сообщение
Yet roAFK is the first include AFK System in Filterscript and Includes section.
https://sampforum.blast.hk/showthread.php?tid=146041

Felt like pointing that out
Nice inc, btw.
Reply
#17

Never notice that roAFK is now the 2nd AFK Include anyway thanks for noting me gonna edit the post
and Thanks.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)