[FilterScript] Auto AFK System
#1

REMOVED
Reply
#2

Not bad..
Reply
#3

That's soo simple but soo good!
Reply
#4

https://sampforum.blast.hk/showthread.php?tid=479616
You just did few edits, Which is nothing.
Reply
#5

GG string size 128

it should be 41 or 42.

Код:
CMD:afk(playerid,params[])// /afk command
{
    new string[128];// Store the intial action
    if(IsAFK[playerid] == 1) return SendClientMessage(playerid, COLOR_RED, "Error: You are already AFK.");
    else // And why using else while the "return" already breaks the code?
    {
        format(string,sizeof(string),"*%s has gone AFK",GetName(playerid));//Formats the /do cmd output
        IsAFK[playerid] = 1;
        SendClientMessageToAll(COLOR_WHITE,string);//Display the output to all clients
    }
    return 1;
}
Код:
CMD:back(playerid,params[])// /back command
{
    new string[128];// Store the intial action
    if(IsAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "Error: You aren't AFK.");
    format(string,sizeof(string),"*%s is back",GetName(playerid));//Formats the /do cmd output
    IsAFK[playerid] = 0;
    SendClientMessageToAll(COLOR_WHITE,string);//Display the output to all clients
    return 1;
}
EDIT:

Код:
forward AFKCheck();
public AFKCheck() // And another huge mistake, you are not checking if the players are online are not,imagine what if there are 10 players playing on a 1000 slots server
{
    new Float:Pos[3] /* Arrays are slower than variables,it should be "new Float:x, Float:y, Float:z"*/, string[128]; // creating an array variable of 3 values whose datatype is Float.
    for(new i = 0; i < MAX_PLAYERS; i++) // Looping through the players.
    {
        if(IsAFK[i] == 1) return 1; //Checks to see if the player is already AFK
        GetPlayerPos(i,Pos[0],Pos[1],Pos[2]); // Gets the player position and saves into their variables.
        if(IsPlayerInRangeOfPoint(i,2,Pos[0],Pos[1],Pos[2])) // If player is around the position (if player is at the same place)
        {
            AFK[i]++; // Increment the AFK variable (for every second if player is at same location, increase the AFK variable by 1)
        }
        if(AFK[i] == SetAFKTime) // Checking to see how long the player has been in the same place, if the varible (AFK) matches (SetAFKTime) it sets the player AFK.
        {
            format(string,sizeof(string),"*%s has gone AFK",GetName(i));//Formats the /do cmd output
            SendClientMessageToAll(COLOR_WHITE,string);
            IsAFK[i] = 1;
        }
    }
    return 1;
}
Reply
#6

make an ANTI-SPAM thingy cause the can keep spamming /afk and /back to spam the server chat
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)