[FilterScript] AFK BACK Simple
#4

pawn Code:
//Variables
new AFK[MAX_PLAYERS];
Okay so I see that you're declaring a new variable, and I am guessing this is to save the player's AFK status.

pawn Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/afk", cmdtext, true, 10) == 0)
    {
        new string[128];
        //
        format(string,sizeof(string),"%s(%d) Is now AFK 'Away From Keyboard'", PlayerName(playerid), playerid);
        SendClientMessageToAll(COLOR_GREEN, string);
        //
        SendClientMessage(playerid,COLOR_YELLOW,"Use /back when your back");
        //
        AFK[playerid] =1;
        //
        TogglePlayerControllable(playerid, 0);
        return 1;
    }
 
    if (strcmp("/back", cmdtext, true, 10) == 0)
    {
        new string[128];
        //
        format(string,sizeof(string),"%s(%d) Is now back on his computer", PlayerName(playerid), playerid);
        SendClientMessageToAll(COLOR_GREEN, string);
        //
        SendClientMessage(playerid,COLOR_YELLOW,"Use /afk if you want to use AFK again");
        //
        AFK[playerid] =0;
        //
        TogglePlayerControllable(playerid, 1);
        return 1;
    }
    return 0;
}
But you're not even using it? What's the point of having it if you're not even using it, you're just setting it to true or false whether they're AFK or not, but you never actually use it in a check such as an 'if' statement.

pawn Code:
stock PlayerName(playerid)
{
  new name[255];
  GetPlayerName(playerid, name, 255);
  return name;
}
This amazed me, you're using a cell size of 255 just to store a player name? You only 24 cells for a player name. So you can just use the reference 'MAX_PLAYER_NAME'.

Anyway I can see that you're new to scripting and newbies do tend to make mistakes, the code may work perfectly fine yes, but the methods used are bad. Again I am not trying to hate or anything, good work for the effort.
Reply


Messages In This Thread
AFK BACK Simple - by daemon3304 - 25.05.2013, 21:09
Re: AFK BACK Simple - by BpVanshVk - 25.05.2013, 22:44
Re: AFK BACK Simple - by daemon3304 - 26.05.2013, 00:07
Re: AFK BACK Simple - by Bicentric - 26.05.2013, 02:11
Re: AFK BACK Simple - by Pottus - 26.05.2013, 02:50
Re : Re: AFK BACK Simple - by thegreathom - 26.05.2013, 03:10
Re: AFK BACK Simple - by daemon3304 - 26.05.2013, 09:20
Re: AFK BACK Simple - by amoitwil - 26.05.2013, 09:49
Re: AFK BACK Simple - by iMTube™ - 26.05.2013, 18:26
Re: AFK BACK Simple - by daemon3304 - 26.05.2013, 18:40

Forum Jump:


Users browsing this thread: 1 Guest(s)