#1

For some reason, non-admins are able to use the /goto command. here is the pastebin version and code itself.

http://pastebin.com/m6f740fe

Код:
if(strcmp(cmd, "/goto", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /goto [playerid/PartOfName]");
				return 1;
			}
			new Float:plocx,Float:plocy,Float:plocz;
			new plo;
			plo = ReturnUser(tmp);
			if (IsPlayerConnected(plo))
			{
			  if(plo != INVALID_PLAYER_ID)
			  {
					if (PlayerInfo[playerid][pAdmin] >= 2)
					{
						if(Spectate[playerid] != 255)
						{
							Spectate[playerid] = 256;
						}
						GetPlayerPos(plo, plocx, plocy, plocz);
						if(PlayerInfo[plo][pInt] > 0)
						{
							SetPlayerInterior(playerid,PlayerInfo[plo][pInt]);
							PlayerInfo[playerid][pInt] = PlayerInfo[plo][pInt];
							PlayerInfo[playerid][pLocal] = PlayerInfo[plo][pLocal];
						}
						if(PlayerInfo[playerid][pInt] == 0)
						{
							SetPlayerInterior(playerid,0);
						}
						if(plocz > 530.0 && PlayerInfo[plo][pInt] == 0) //the highest land point in sa = 526.8
						{
							SetPlayerInterior(playerid,1);
							PlayerInfo[playerid][pInt] = 1;
						}
						if (GetPlayerState(playerid) == 2)
						{
							new tmpcar = GetPlayerVehicleID(playerid);
							SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
							TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
						}
						else
						{
							SetPlayerPos(playerid,plocx,plocy+2, plocz);
						}
						SendClientMessage(playerid, COLOR_GRAD1, "  You have been teleported");
					}
					else
					{
						SendClientMessage(playerid, COLOR_GRAD1, "  You are not authorized to use that command!");
					}
				}
			}
			else
			{
				format(string, sizeof(string), "  %d is not an active player.", plo);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
Reply
#2

do this
pawn Код:
if(strcmp(cmd, "/goto", true) == 0)
    {
      if(IsPlayerAdmin(playerid))
  {
  if(IsPlayerConnected(playerid))
      {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /goto [playerid/PartOfName]");
                return 1;
            }
            new Float:plocx,Float:plocy,Float:plocz;
            new plo;
            plo = ReturnUser(tmp);
            if (IsPlayerConnected(plo))
            {
              if(plo != INVALID_PLAYER_ID)
              {
                    if (PlayerInfo[playerid][pAdmin] >= 2)
                    {
                        if(Spectate[playerid] != 255)
                        {
                            Spectate[playerid] = 256;
                        }
                        GetPlayerPos(plo, plocx, plocy, plocz);
                        if(PlayerInfo[plo][pInt] > 0)
                        {
                            SetPlayerInterior(playerid,PlayerInfo[plo][pInt]);
                            PlayerInfo[playerid][pInt] = PlayerInfo[plo][pInt];
                            PlayerInfo[playerid][pLocal] = PlayerInfo[plo][pLocal];
                        }
                        if(PlayerInfo[playerid][pInt] == 0)
                        {
                            SetPlayerInterior(playerid,0);
                        }
                        if(plocz > 530.0 && PlayerInfo[plo][pInt] == 0) //the highest land point in sa = 526.8
                        {
                            SetPlayerInterior(playerid,1);
                            PlayerInfo[playerid][pInt] = 1;
                        }
                        if (GetPlayerState(playerid) == 2)
                        {
                            new tmpcar = GetPlayerVehicleID(playerid);
                            SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                            TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
                        }
                        else
                        {
                            SetPlayerPos(playerid,plocx,plocy+2, plocz);
                        }
                        SendClientMessage(playerid, COLOR_GRAD1, "  You have been teleported");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "  You are not authorized to use that command!");
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "  %d is not an active player.", plo);
                SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 1;
i think it will work! just unindent, xD to lazy maself
Reply
#3

Neither of these worked. I'm still able to tp to a player as a non-admin.
Reply
#4

what gm you use?
Reply
#5

Quote:
Код:
...
if (IsPlayerConnected(plo) & plo != INVALID_PLAYER_ID)
...
this won't work as expected, you need && instead of single & (& is bitwise AND)
Quote:
Originally Posted by » ραωпsтαг «
You don't need to check if the player who is using the command is connected .. because if he is using the command, he's quite obviously connected lol
Checking if the player to be teleported to is connected is not a bad idea.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)