Auto AFK
#1

I have just noticed that some players are abusing score farming chat kill, or let say, If player is typing something and a random guy appear from nowhere and shoots the guy who is busy typing and he died.
Is that possible if a player stop doing any movements Then set/make him as AFK. Even he didn't use Esc?
Reply
#2

Here, i had this FS downloaded it from somewhere i dont remember, what it does is, if player wont move for 15 mins it sets their status as AFK and makes them invisible (change vw id)

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

forward Timer(playerid);

#if defined FILTERSCRIPT

enum Info
{
    OldX,
    OldY,
    OldZ,
    AFK,

}

new Player[MAX_PLAYERS][Info];


public OnFilterScriptInit()
{
    print("Loading AFK System");
    print("LOADED");
    SetTimer("Timer", 1000, true);
    return 1;
}

public Timer(playerid)
{
    new Virtualworld;
    new Float:x, Float:y, Float:z;
    Virtualworld = GetPlayerVirtualWorld(playerid);
   
    if(Virtualworld = 0 || (Virtualworld = 1))
    {
        if(Player[playerid][AFK] = 0) //Only players not considered AFK yet will be checked for their location
        {
            GetPlayerPos(playerid,x,y,z);
            // Saving the current locations
            Player[playerid][OldX] = x;
            Player[playerid][OldY] = y;
            Player[playerid][OldZ] = z;
            Player[playerid][AFK] = 1; //Sets on AFK = 1, will only activate a timer and not do any changes to the player
       
        }
        if(Player[playerid][AFK] >=1)
        {
            GetPlayerPos(playerid,x,y,z);
            if(x = Player[playerid][OldX]) //The old positions are from above
            {
                if(y = Player[playerid][OldY])
                {
                    if(z = Player[playerid][OldZ])
                    {
                        Player[playerid][AFK] + 1; //Player is marked a posible AFK'er right now. It keeps adding this each second upon no move
                       
                        if(Player[playerid][AFK] == 900 && (Virtualworld = 0)) //Player is detected to be AFK for 15 minutes (900 seconds) Already AFK players won't be placed AFK again
                        {
                            SetPlayerVirtualWorld(playerid, 1); //Player is made invisible!
                            SendClientMessage(playerid, 0xFFD7004A, "You were made invisible as you're AFK for more than 15 minutes!");
                        }
                   
                    }
                }
           
            }
            else
            {
                if(Player[playerid][AFK] >= 900) //Player is invisible + AFK
                {
                    Player[playerid][AFK] = 0; //Timer reset
                    SetPlayerVirtualWorld(playerid, 0);
                    SendClientMessage(playerid, 0xFFD7004A, "Welcome back ingame! You're visible again!");
               
                }
                else
                {
                    Player[playerid][AFK] = 0; //Timer reset
                }
            }
       
        }
   
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new Virtualworld;
    Virtualworld = GetPlayerVirtualWorld(playerid);
    if(Player[playerid][AFK] >= 900 && (Virtualworld = 1))
    {
        Player[playerid][AFK] = 0; //Timer reset
        SetPlayerVirtualWorld(playerid, 0);
        //Quicky makes the player visible before disconnecting to prevent bugs on servers with stored positions, like most RP servers
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    Player[playerid][AFK] = 0; //Player says something so he is not away from keyboard so his AFK timer resets
    return 1;
}
#endif
Reply
#3

Quote:
Originally Posted by RanSEE
Посмотреть сообщение
Here, i had this FS downloaded it from somewhere i dont remember, what it does is, if player wont move for 15 mins it sets their status as AFK and makes them invisible (change vw id)

pawn Код:
#define FILTERSCRIPT

#include <a_samp>

forward Timer(playerid);

#if defined FILTERSCRIPT

enum Info
{
    OldX,
    OldY,
    OldZ,
    AFK,

}

new Player[MAX_PLAYERS][Info];


public OnFilterScriptInit()
{
    print("Loading AFK System");
    print("LOADED");
    SetTimer("Timer", 1000, true);
    return 1;
}

public Timer(playerid)
{
    new Virtualworld;
    new Float:x, Float:y, Float:z;
    Virtualworld = GetPlayerVirtualWorld(playerid);
   
    if(Virtualworld = 0 || (Virtualworld = 1))
    {
        if(Player[playerid][AFK] = 0) //Only players not considered AFK yet will be checked for their location
        {
            GetPlayerPos(playerid,x,y,z);
            // Saving the current locations
            Player[playerid][OldX] = x;
            Player[playerid][OldY] = y;
            Player[playerid][OldZ] = z;
            Player[playerid][AFK] = 1; //Sets on AFK = 1, will only activate a timer and not do any changes to the player
       
        }
        if(Player[playerid][AFK] >=1)
        {
            GetPlayerPos(playerid,x,y,z);
            if(x = Player[playerid][OldX]) //The old positions are from above
            {
                if(y = Player[playerid][OldY])
                {
                    if(z = Player[playerid][OldZ])
                    {
                        Player[playerid][AFK] + 1; //Player is marked a posible AFK'er right now. It keeps adding this each second upon no move
                       
                        if(Player[playerid][AFK] == 900 && (Virtualworld = 0)) //Player is detected to be AFK for 15 minutes (900 seconds) Already AFK players won't be placed AFK again
                        {
                            SetPlayerVirtualWorld(playerid, 1); //Player is made invisible!
                            SendClientMessage(playerid, 0xFFD7004A, "You were made invisible as you're AFK for more than 15 minutes!");
                        }
                   
                    }
                }
           
            }
            else
            {
                if(Player[playerid][AFK] >= 900) //Player is invisible + AFK
                {
                    Player[playerid][AFK] = 0; //Timer reset
                    SetPlayerVirtualWorld(playerid, 0);
                    SendClientMessage(playerid, 0xFFD7004A, "Welcome back ingame! You're visible again!");
               
                }
                else
                {
                    Player[playerid][AFK] = 0; //Timer reset
                }
            }
       
        }
   
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new Virtualworld;
    Virtualworld = GetPlayerVirtualWorld(playerid);
    if(Player[playerid][AFK] >= 900 && (Virtualworld = 1))
    {
        Player[playerid][AFK] = 0; //Timer reset
        SetPlayerVirtualWorld(playerid, 0);
        //Quicky makes the player visible before disconnecting to prevent bugs on servers with stored positions, like most RP servers
    }
    return 1;
}

public OnPlayerText(playerid, text[])
{
    Player[playerid][AFK] = 0; //Player says something so he is not away from keyboard so his AFK timer resets
    return 1;
}
#endif
Hi ransee thanks for your reply. Can I change 15 mins to 2 Seconds? Also make the virtual world simple, like when I'm im in Virtual World 3, then 2 seconds counts(afk mode) then don't set to anyworld just stay me on Virtual world 3. How?
Reply
#4

Remove that code if you don't want that.
Reply
#5

Quote:
Originally Posted by TaLhA XIV
Посмотреть сообщение
Remove that code if you don't want that.
EDIT: It's not just removing..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)