[Help] Afk Command
#1

So here is what I have done:

PHP код:
YCMD:afk(playeridparams[], help)
{
    new 
reason[64], strtext[64];
    if(
IsPlayerAFK[playerid] == 1) return SendClientMessage(playerid0xFB0000AA"ERROR: You are already AFK.");
    if(
sscanf(params,"s[64]"reason)) return SendClientMessage(playerid0xF6BB0AA"USAGE: /afk [reason]");
    
IsPlayerAFK[playerid] = 1;
    
TogglePlayerControllable(playeridfalse);
    new 
string[64], plname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplnameMAX_PLAYER_NAME);
    
format(stringsizeof(string), "* %s(%d) is now AFK - %s",plname,playerid,reason);
    
SendClientMessageToAll(COLOR_WHITEstring);
    
format(strtextsizeof(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], playerid0.00.00.3);
    
SendClientMessage(playeridCOLOR_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 
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
PHP код:
*X is now AFK BRB <--This is the reason 
And when the Player X does /afk again
PHP код:
*X is now back BRB <-- Shows that whatever reason he typed when he got afk 
This is the cmd that i used right now, but i wan't it to have the /afk to go back cmd
PHP код:
YCMD:back(playeridparams[], help)
{
 new 
reason[64];
 if(
IsPlayerAFK[playerid] == 0) return SendClientMessage(playeridCOLOR_WHITE"You are not AFK.");
 if(
sscanf(params,"s[64]"reason))
    
IsPlayerAFK[playerid] = 0;
    
TogglePlayerControllable(playeridtrue);
    new 
string[64], plname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplnameMAX_PLAYER_NAME);
    
format(stringsizeof(string), "* %s(%d) is now back - %s",plname,playerid,reason);
    
SendClientMessageToAll(COLOR_WHITEstring);
    
Delete3DTextLabel(Text3D:AFK_Label[playerid]);
    
SendClientMessage(playeridCOLOR_WHITE"You are no longer AFK.");
    return 
1;

Reply
#2

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
Reply
#3

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
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
Can you the post the result, cause i don't know how to use bool
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)