17.05.2016, 15:23
To cause you less confusion, I just edited your code.
PHP код:
COMMAND:afk(playerid, params[])
{
SendAdminText(playerid, "/afk", params);
if (APlayerData[playerid][LoggedIn] == false) return 0;
if (GetPVarInt(playerid, "AFK") == 1)
return SendClientMessage(playerid, -1, "You are already AFK!");
new Name[24], string[128];
TogglePlayerControllable(playerid,0);
GetPlayerName(playerid, Name, sizeof(Name));
SetPVarString(playerid, "PreviousName", Name);
SetPVarInt(playerid, "AFK", 1); // To indicate that the player is AFK
format(string, sizeof(string), "%s[AFK]", Name);
SetPlayerName(playerid, string);
format(string, sizeof(string), "Le joueur %s c'est mis afk !", Name);
SendClientMessageToAll(-1, string);
// message afk
SendClientMessage(playerid, -1, "Vous etes maintenant afk !");
return 1;
}
COMMAND:stopafk(playerid, params[])
{
SendAdminText(playerid, "/stopafk", params);
if (APlayerData[playerid][LoggedIn] == false) return 0;
if (GetPVarInt(playerid, "AFK") == 0)
return SendClientMessage(playerid, -1, "You are not AFK!");
new Name[24], string[128];
TogglePlayerControllable(playerid, 1);
GetPVarString(playerid, "PreviousName", Name, sizeof(Name));
SetPlayerName(playerid, Name);
format(string, sizeof(string),"Le joueur %s est de retour !", Name);
SendClientMessageToAll(-1, string);
// message afk
SendClientMessage(playerid,-1, "Vous etes maintenant de retour !");
DeletePVar(playerid, "PreviousName");
SetPVarInt(playerid, "AFK", 0);
return 1;
}