Help me Afk And Back CMDS
#1

I Have These 2 Commands How I Can Make Pwano if
Player Already Afk And Typed AFK SCM You Are Already AFK
if
Player Not AFK and typed /back scm You are not AFK
Please Help me


This is CODE:
Код:
CMD:afk(playerid, params[])
{
	new name[MAX_PLAYER_NAME], string[128];
	GetPlayerName(playerid, name, MAX_PLAYER_NAME);
	format(string, sizeof(string), "%s Is Now Afk.", name);
	SCMTA(0xFFFF00, string);
	TogglePlayerControllable(playerid, 0);
	return 1;

}
//==============================================================================
CMD:back(playerid, params[])
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(string, sizeof(string), "%s back from Afk.", name);
    SCMTA(0xFFFF00, string);
    TogglePlayerControllable(playerid, true);
    return 1;
}
//==============================================================================
Reply
#2

PHP код:
new bool:afkcheck[MAX_PLAYERS];// on top of the script (creating a variable to check for on/off stats)
CMD:afk(playeridparams[])//afk cmd
{
    if(!
afkcheck[playerid])//checking if he's not afk (!)
     
{
        new 
name[MAX_PLAYER_NAME], string[40];
        
GetPlayerName(playeridnameMAX_PLAYER_NAME);
        
format(stringsizeof(string), "%s Is Now Afk."name);
        
SCMTA(0xFFFF00string);
        
TogglePlayerControllable(playerid0);
        
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(playeridparams[])//back cmd
{
    if(
afkcheck[playerid])//checking if he's afk 
     
{
        new 
name[MAX_PLAYER_NAME], string[40];
        
GetPlayerName(playeridnameMAX_PLAYER_NAME);
        
format(stringsizeof(string), "%s back from Afk."name);
        
SCMTA(0xFFFF00string);
        
TogglePlayerControllable(playeridtrue);
        
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;

but don't forget to put afkcheck[playerid]=false; underneath OnPlayerSpawn in case if a player logs out while afk.
Reply
#3

string[40]; is enough no need 128
Reply
#4

Quote:
Originally Posted by Lokii
Посмотреть сообщение
string[40]; is enough no need 128
True i'll edit the code i made for him too.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)