[FilterScript] Simple AFK System.
#1

Introduction.
Hello, my name is Juan Viz, most known as Phantom, I'm new in things like scripting, I already have some map releases but I though I needed to go to another level and do something like this so enjoy!
Code | Download
pawn Код:
/*

Filterscript created by: Phantom
Credits:
lelemaster for helping me while doing the script.
V1ceC1ty for helping me while doing the script aswell.
Akira297 for insipiring me to script.
Note: If you release / use it on any webpage or gamemode give me credits.
Feel free to Edit/remove/add lines of code to the FS.
SA:MP Forums


*/

#define Filterscript
#include <a_samp>
new pAFK[MAX_PLAYERS] = 0;
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
        print("\n--------------------------------------");
        print(" Away from keyboard FS Loaded");
        print("--------------------------------------\n");
        return 1;
}

public OnFilterScriptExit()
{
        return 1;
}

#else

main()
{
        print("\n----------------------------------");
        print(" Away from keyboard FS Unloaded");
        print("----------------------------------\n");
}
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/afk", cmdtext, true, 10) == 0)
    {
        if(pAFK[playerid] == 1)
        {
            SendClientMessage(playerid, 0xEFEFF7AA, "You are already AFK! As you typed this, it means you are back!");
            SetPlayerHealth(playerid, 100);
            pAFK[playerid] == 0;
        }
        else if(pAFK[playerid] == 0)
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "You are now AFK!");
            SetPlayerVirtualWorld(playerid, 69696969);
            pAFK[playerid] == 1;
            SetPlayerHealth(playerid, 9999999);
        }
        return 1;
    }
    if (strcmp("/back", cmdtext, true, 10) == 0)
    {
        if(pAFK[playerid] == 0)
        {
            SendClientMessage(playerid, 0xEFEFF7AA, "You are not even AFK!!");
        }
        else if(pAFK[playerid] == 1)
        {
            pAFK[playerid] == 0;
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerHealth(playerid, 100);
            SendClientMessage(playerid, 0xFFFFFFFF, "You are now back");
        }
        return 1;
    }
    return 0;
}

public OnPlayerDisconnect(playerid)
{
    pAFK[playerid] = 0;
    return 1;
}
public OnPlayerConnect(playerid)
{
        pAFK[playerid] == 0;
}
#endif
Код:
Changelog
-V0.1 Released --First release -V0.2 Released --Removed useless line of codes --HP Sets to 99999 when you /AFK --HP Sets to 100 when you /back --HP Sets to 100 when you /AFK While being AFK, which means automaticly comming back. For more information about the last update on the V0.2 read the first line of /AFK
Well thats all, thanks for downloading or using this, enjoy!

Updated to V0.2
Removed useless coding.


NOTE: Make sure to add #define Filterscript at the top of the script (if you download it/use pastebin) or it won't work.
Reply
#2

I've seen this inside scripting help. Nice Job though.
Reply
#3

Quote:
Originally Posted by Yamakei
Посмотреть сообщение
I've seen this inside scripting help. Nice Job though.
Yeah, check the credits, they both helped me on it, still I "Customized" it abit, I'm thinking on upgrading it so it has more than a normal AFK System, maybe more functions.

Edit: Thanks for the feedback btw.
Reply
#4

Why is this in the format as a Gamemode and not as a FilterScript?
Reply
#5

Quote:
Originally Posted by NoahF
Посмотреть сообщение
Why is this in the format as a Gamemode and not as a FilterScript?
Its formated as a Filterscript.. Atleast thats what I know..
Reply
#6

#define FILTERSCRIPT needs to be at the top.
Reply
#7

Also take out the MAIN() code..
Reply
#8

isnt this mine with the words changed lol :S?
Reply
#9

I dont think so, Hanshish, I postedma help topic on scripting help and its based on it, but you have to understand that almost every single. AFK FS is similar
Reply
#10

Take this:
Код:
main()
{
        print("\n----------------------------------");
        print(" Away from keyboard FS Unloaded");
        print("----------------------------------\n");
}
Put the prints in the "public OnFilterScriptExit()" callback, and delete out the Main().
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)