02.09.2018, 12:13
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.
Step 2:
Second of all we need variables which we will use in command.
Step 3:
Now we need command from which player will go afk and can come back from afk.
So this was the tutorial which i made and i know i didn't explain that much good so sorry for that i will make good tutorial's soon so wait for them thanks for checking it out.
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>
Second of all we need variables which we will use in command.
PHP Code:
/* Variables */
new AFKMode[MAX_PLAYERS];
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;
}
So this was the tutorial which i made and i know i didn't explain that much good so sorry for that i will make good tutorial's soon so wait for them thanks for checking it out.