YCMD:afk(playerid, params[], help)
{
new reason[64], strtext[64];
if(IsPlayerAFK[playerid] == 1) return SendClientMessage(playerid, 0xFB0000AA, "ERROR: You are already AFK.");
if(sscanf(params,"s[64]", reason)) return SendClientMessage(playerid, 0xF6BB0AA, "USAGE: /afk [reason]");
IsPlayerAFK[playerid] = 1;
TogglePlayerControllable(playerid, false);
new string[64], plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, MAX_PLAYER_NAME);
format(string, sizeof(string), "* %s(%d) is now AFK - %s",plname,playerid,reason);
SendClientMessageToAll(COLOR_WHITE, string);
format(strtext, sizeof(strtext), ""LBLUE"Player is AFK\n"WHITE"Reason - %s", reason);
AFK_Label[playerid] = Create3DTextLabel(strtext,COLOR_WHITE,30.0,40.0,50.0,40.0,0);
Attach3DTextLabelToPlayer(AFK_Label[playerid], playerid, 0.0, 0.0, 0.3);
SendClientMessage(playerid, COLOR_WHITE, "You are now AFK,type "LBLUE"/back "WHITE"when you come back.");
return 1;
}
"*%s(%d) is now back - %s",plname,playerid,reason
*X is now AFK - BRB <--This is the reason
*X is now back - BRB <-- Shows that whatever reason he typed when he got afk
YCMD:back(playerid, params[], help)
{
new reason[64];
if(IsPlayerAFK[playerid] == 0) return SendClientMessage(playerid, COLOR_WHITE, "You are not AFK.");
if(sscanf(params,"s[64]", reason))
IsPlayerAFK[playerid] = 0;
TogglePlayerControllable(playerid, true);
new string[64], plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, MAX_PLAYER_NAME);
format(string, sizeof(string), "* %s(%d) is now back - %s",plname,playerid,reason);
SendClientMessageToAll(COLOR_WHITE, string);
Delete3DTextLabel(Text3D:AFK_Label[playerid]);
SendClientMessage(playerid, COLOR_WHITE, "You are no longer AFK.");
return 1;
}
Define a boolean or an AFK variable,when it's false(0)[the player isn't AFK] it makes him go AFK(meanwhiled change the boolean/variable to true/1],and if the boolean/variable it's true/1,then make him go back,in the game,and redefine the boolean/variable to false/0.Everytime the player uses the command check the boolean/variable in order to know what to do
|