[FilterScript] Auto AFK System
#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


Messages In This Thread
Auto AFK System - by Tass007 - 24.08.2016, 12:02
Re: Auto AFK System - by Younes44 - 24.08.2016, 12:54
Re: Auto AFK System - by Moersy - 24.08.2016, 13:12
Re: Auto AFK System - by oMa37 - 24.08.2016, 13:24
Re: Auto AFK System - by K0P - 24.08.2016, 16:14
Re: Auto AFK System - by SeanDenZYR - 25.08.2016, 11:20

Forum Jump:


Users browsing this thread: 1 Guest(s)