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.