01.01.2018, 12:13
PHP код:
new bool:afkcheck[MAX_PLAYERS];// on top of the script (creating a variable to check for on/off stats)
CMD:afk(playerid, params[])//afk cmd
{
if(!afkcheck[playerid])//checking if he's not afk (!)
{
new name[MAX_PLAYER_NAME], string[40];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s Is Now Afk.", name);
SCMTA(0xFFFF00, string);
TogglePlayerControllable(playerid, 0);
afkcheck[playerid]=true;//making the check count true when enabling afk
}
else//if he's already afk
{
SendClientMessage(playerid,-1,"You're already afk!");
}
return 1;
}
//==============================================================================
CMD:back(playerid, params[])//back cmd
{
if(afkcheck[playerid])//checking if he's afk
{
new name[MAX_PLAYER_NAME], string[40];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s back from Afk.", name);
SCMTA(0xFFFF00, string);
TogglePlayerControllable(playerid, true);
afkcheck[playerid]=false;//making the variable count as false when he comes back from afk
}
else//if he isn't afk
{
SendClientMessage(playerid,-1,"You're not afk!");
}
return 1;
}