Help me Afk And Back CMDS - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help me Afk And Back CMDS (
/showthread.php?tid=647222)
Help me Afk And Back CMDS -
Osamakurdi - 01.01.2018
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;
}
//==============================================================================
Re: Help me Afk And Back CMDS -
RogueDrifter - 01.01.2018
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;
}
but don't forget to put
afkcheck[playerid]=false; underneath
OnPlayerSpawn in case if a player logs out while afk.
Re: Help me Afk And Back CMDS -
Lokii - 01.01.2018
string[
40]; is enough no need 128
Re: Help me Afk And Back CMDS -
RogueDrifter - 01.01.2018
Quote:
Originally Posted by Lokii
string[40]; is enough no need 128
|
True i'll edit the code i made for him too.