14.04.2012, 05:37
So here is what I have done:
Now, how do I make it so that when the player do /afk again, it will let them go back
2nd, How can i make it get the information when the player states the reason when he did the /afk cmd
so it will look like this
When Player X is afk
And when the Player X does /afk again
This is the cmd that i used right now, but i wan't it to have the /afk to go back cmd
PHP код:
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;
}
Now, how do I make it so that when the player do /afk again, it will let them go back
PHP код:
"*%s(%d) is now back - %s",plname,playerid,reason
so it will look like this
When Player X is afk
PHP код:
*X is now AFK - BRB <--This is the reason
PHP код:
*X is now back - BRB <-- Shows that whatever reason he typed when he got afk
PHP код:
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;
}