Introduction

I made a simple AFK/BACK system for those who are noob in scripting and i used [YSI] as my saving system so hope you learn something from it and its my first time making a post on forums so hope you enjoy it Thanks.

Tutorial


Step 1:

First of all we need includes which will make the command work.

PHP Code:
/* Includes */
#include <a_samp>
#include <YSI\y_ini>
#include <zcmd>
Step 2:

Second of all we need variables which we will use in command.

PHP Code:
/* Variables */
new AFKMode[MAX_PLAYERS];
Step 3:

Now we need command from which player will go afk and can come back from afk.

PHP Code:
/* Commands */
CMD:afk(playerid, params[])
{
if (AFKMode[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are already AFK."); //If player is already afk it will send a message to him saying you are already afk.
AFKMode[playerid] = 1; //This will change the variable to 1.
new string[256], pname[MAX_PLAYER_NAME]; //New variables.
GetPlayerName(playerid, pname, sizeof(string)); //This will get the player name.
TogglePlayerControllable(playerid, 0); //The player will not be able to move.
format(string, sizeof(string), "%s is now AFK.", pname);
SendClientMessageToAll(COLOR_YELLOW, string); //This will send the message to all that the player is afk now.
return 1;
}
CMD:back(playerid, params[])
{
if (!AFKMode[playerid]) return SendClientMessage(playerid, COLOR_RED, "You are not afk."); //If player is not afk it will send a message to him saying you are not afk.
AFKMode[playerid] = 0; //This will change the variable to 0.
new string[256], pname[MAX_PLAYER_NAME]; //New variables.
GetPlayerName(playerid, pname, sizeof(string)); //This will get the player name.
TogglePlayerControllable(playerid, 1); //The player will be able to move.
format(string, sizeof(string), "%s is now back from afk.", pname);
SendClientMessageToAll(COLOR_YELLOW, string); //This will send the message to all that the player is afk now.
return 1;
}