SA-MP Forums Archive
/goto - 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: /goto (/showthread.php?tid=119845)



/goto - marine - 09.01.2010

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;
	}



Re: /goto - patchkinson - 09.01.2010

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


Re: /goto - marine - 09.01.2010

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


Re: /goto - whitedragon - 09.01.2010

what gm you use?


Re: /goto - Streetplaya - 09.01.2010

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.