SA-MP Forums Archive
Back command help - 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: Back command help (/showthread.php?tid=541305)



Back command help - YanLanger - 11.10.2014

FIXED


Re: Back command help - GwENiko - 11.10.2014

top of your script
pawn Код:
bool:IsPlayerAFK[MAX_PLAYERS];
pawn Код:
CMD:back(playerid,params[])
{
 if(IsPlayerAfk[playerid] == false) return SendClientMessage(playerid, -1, "{FF0000}[SERVER]{ffffff}:You are not AFK");
 if(IsPlayerAfk[playerid] == true) TogglePlayerControllable(playerid,1);
 IsPlayerAFK[playerid] = false;
 return 1;
}
and show your afk cmd, just in-case.


Re: Back command help - YanLanger - 11.10.2014

FIXED


Re: Back command help - Shaktimaan - 11.10.2014

show /afk


Re: Back command help - Stinged - 11.10.2014

Show me both, /afk and the line where it has IsPlayerAfk[MAX_PLAYERS];

And here's the fixed command:
pawn Код:
CMD:back(playerid,params[])
{
    if(IsPlayerAfk[playerid] == 0) return SendClientMessage(playerid, -1, "{FF0000}[SERVER]{ffffff}:You are not AFK");
    else
    {
        TogglePlayerControllable(playerid, 1);
        IsPlayerAfk[playerid] == 0;
    }
    return 1;
}
pawn Код:
CMD:afk(playerid, params[])
{
    if(IsPlayerAfk[playerid] == 0)
    {
        TogglePlayerControllable(playerid, 0);
        GameTextForPlayer(playerid, "~g~AFK",5000,3);
                IsPlayerAfk[playerid] = 1;
    }
    else
    {  
        SendClientMessage(playerid, -1, "You are already AFK");
    }
    return 1;
}
Why don't use put brackets? I've noticed that in all of your scripting help topics.


Re: Back command help - GwENiko - 11.10.2014

it will go:
pawn Код:
if(IsPlayerAfk[playerid] == true) return SendClientMessage(playerid, -1, "You are already AFK.");
if(IsPlayerAfk[playerid] == false)  TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "~g~AFK",5000,3);



Re: Back command help - YanLanger - 11.10.2014

FIXED


Re: Back command help - Shaktimaan - 11.10.2014

pawn Код:
CMD:afk(playerid, params[])
{
 if(IsPlayerAfk[playerid] == 0){
 IsPlayerAfk[playerid] = 1;
 TogglePlayerControllable(playerid, 0);
 GameTextForPlayer(playerid, "~g~AFK",5000,3);
 }
 return 1;
}
CMD:back(playerid,params[])
{
 if(IsPlayerAfk[playerid] == 0) return SendClientMessage(playerid, -1, "{FF0000}[SERVER]{ffffff}:You are not AFK");
 if(IsPlayerAfk[playerid] == 1)
 {
 IsPlayerAfk[playerid] = 0;
 TogglePlayerControllable(playerid,1);
 }
 return 1;
}



Re: Back command help - GwENiko - 11.10.2014

Just let me know, if the command satisfies what you were trying to do.

pawn Код:
CMD:afk(playerid, params)
{
if(IsPlayerAfk[playerid] == true) return SendClientMessage(playerid, -1, "You are already AFK.");
if(IsPlayerAfk[playerid] == false)  TogglePlayerControllable(playerid, 0);
GameTextForPlayer(playerid, "~g~AFK",5000,3);
return 1;
}
CMD:back(playerid,params[])
{
 if(IsPlayerAfk[playerid] == false) return SendClientMessage(playerid, -1, "{FF0000}[SERVER]{ffffff}:You are not AFK");
 if(IsPlayerAfk[playerid] == true) TogglePlayerControllable(playerid,1);
 IsPlayerAfk[playerid] = false;
 return 1;

public OnPlayerDisconnect(playerid)
{
   IsPlayerAfk[playerid] = false;
   return 1;
}
public OnPlayerConnect(playerid)
{
  IsPlayerAfk[playerid] = false;
  return;
}
this is the straight output

EDIT: also a quote from below
Quote:

Make sure to set IsPlayerAfk[playerid] to 0 under OnPlayerDisconnect or OnPlayerConnect, or it will bug.




Re: Back command help - Stinged - 11.10.2014

You aren't setting a value to IsPlayerAfk[playerid] and you expect it to work?
I fixed that in the commands I posted.

Make sure to set IsPlayerAfk[playerid] to 0 under OnPlayerDisconnect or OnPlayerConnect, or it will bug.