SA-MP Forums Archive
Reading All Three Commands - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Reading All Three Commands (/showthread.php?tid=218599)



Reading All Three Commands - Joshua1987 - 30.01.2011

When not a staff rank, and I entire any of the commands it says the following!
You need to be a helper to use gotos command!
You need to be a helper to use agateo command!
You need to be a helper to use agatec command!

How do i fix the code, so it does not give you all three commands when you only enter gotos, because when I do gotos it says all three commands, should only say one!

Код:
if(AccountInfo[playerid][aLevel] <= 0) SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotos command!");
 else
    if(strcmp(cmdtext, "/gotos", true) == 0)
    {
       SetPlayerPos(playerid, -1470.45617676,2611.21215820,59.36460875);
              SendClientMessage(playerid,red, "Welcome to Staff Base.");
               return 1;
    }
    	if(AccountInfo[playerid][aLevel] <= 0) SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use agateo command!");
else
	if(strcmp(cmdtext, "/agateo", true)==0)
    {
		SendClientMessage(playerid, COLOR_RED, "You have opened the staff gate!");
        MoveObject(agate, -1481.26208496,2660.61840820,48, 3);
        return 1;
    }
    	if(AccountInfo[playerid][aLevel] <= 0) SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use agatec command!");
else
        if(strcmp(cmdtext, "/agatec", true)==0)
    {
		SendClientMessage(playerid, COLOR_RED, "You have closed the staff gate!");
        MoveObject(agate, -1481.26208496,2660.61840820,56.58593750, 3);
        return 1;
    }



AW: Reading All Three Commands - Nero_3D - 30.01.2011

You need to put the rank checks in the commands with a return like
pawn Код:
if(strcmp(cmdtext, "/gotos", true) == 0)
{
    if(AccountInfo[playerid][aLevel] <= 0)
        return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotos command!");
    SetPlayerPos(playerid, -1470.45617676,2611.21215820,59.36460875);
    SendClientMessage(playerid,red, "Welcome to Staff Base.");
    return 1;
}
But I like this methode, so the unqualified people get a Unknown Command error
pawn Код:
if(AccountInfo[playerid][aLevel] > 0)
{
    if(strcmp(cmdtext, "/gotos", true) == 0)
    {
        SetPlayerPos(playerid, -1470.45617676,2611.21215820,59.36460875);
        SendClientMessage(playerid,red, "Welcome to Staff Base.");
        return 1;
    }
    if(strcmp(cmdtext, "/agateo", true)==0)
    {
        SendClientMessage(playerid, COLOR_RED, "You have opened the staff gate!");
        MoveObject(agate, -1481.26208496,2660.61840820,48, 3);
        return 1;
    }
    if(strcmp(cmdtext, "/agatec", true)==0)
    {
        SendClientMessage(playerid, COLOR_RED, "You have closed the staff gate!");
        MoveObject(agate, -1481.26208496,2660.61840820,56.58593750, 3);
        return 1;
    }
}



Re: Reading All Three Commands - Joshua1987 - 30.01.2011

Well I did the first one, and it still doing the three command reading.

Код:
if(AccountInfo[playerid][aLevel] <= 0) SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotos command!");
 else
    if(strcmp(cmdtext, "/gotos", true) == 0){    if(AccountInfo[playerid][aLevel] <= 0)        return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotos command!");    SetPlayerPos(playerid, -395.12805176,1745.45959473,30);    SendClientMessage(playerid,red, "Welcome to Staff Base.");    return 1;}
    	if(AccountInfo[playerid][aLevel] <= 0) SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use agateo command!");
else
if(strcmp(cmdtext, "/agateo", true) == 0){    if(AccountInfo[playerid][aLevel] <= 0)        return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotoo command!");    MoveObject(agate,-393.12805176,1745.45959473,30, 3);   SendClientMessage(playerid,red, "Welcome to Staff Base.");    return 1;}
    	if(AccountInfo[playerid][aLevel] <= 0) SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use agatec command!");
else
if(strcmp(cmdtext, "/agatec", true) == 0){    if(AccountInfo[playerid][aLevel] <= 0)        return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotoc command!");    MoveObject(agate, -393.12805176,1745.45959473,42.42666626, 3);   SendClientMessage(playerid,red, "You're leaving staff base.");    return 1;}



AW: Re: Reading All Three Commands - Nero_3D - 31.01.2011

Yes of course, you didnt removed the check outside the command -_-

pawn Код:
if(strcmp(cmdtext, "/gotos", true) == 0) if(AccountInfo[playerid][aLevel] <= 0) return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotos command!"); else return SetPlayerPos(playerid, -395.12805176,1745.45959473,30), SendClientMessage(playerid,red, "Welcome to Staff Base.");
if(strcmp(cmdtext, "/agateo", true) == 0) if(AccountInfo[playerid][aLevel] <= 0) return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotoo command!"); else return MoveObject(agate,-393.12805176,1745.45959473,30, 3), SendClientMessage(playerid,red, "Welcome to Staff Base.");
if(strcmp(cmdtext, "/agatec", true) == 0) if(AccountInfo[playerid][aLevel] <= 0) return SendClientMessage(playerid, COLOR_RED, "You need to be a Helper to use gotoc command!"); else return MoveObject(agate, -393.12805176,1745.45959473,42.42666626, 3), SendClientMessage(playerid,red, "You're leaving staff base.");