SA-MP Forums Archive
Need teleport 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need teleport help. (/showthread.php?tid=71393)



Need teleport help. - faeain - 31.03.2009

Hello. Im trying to code a /elevator menu that i can access from 3 diffrent locations.
Код:
	if(strcmp(cmdtext, "/elevator", true) == 0 || strcmp(cmd, "/ele", true) == 0)
	{
			if(PlayerToPoint(10, playerid,1525.4550,-1677.8188,5.8906))
			if(PlayerToPoint(10, playerid,215.4959,125.4498,1003.2188))
			if(PlayerToPoint(10, playerid,1564.4706,-1665.4108,28.3956))
Im sure this is not the way to do it. the whole code works but only if i have one of those 3. so what do i have to do to get access to the menu from all the 3?
Thanks.


Re: Need teleport help. - Pyrokid - 01.04.2009

pawn Код:
if(PlayerToPoint(10, playerid,1525.4550,-1677.8188,5.8906) || PlayerToPoint(10, playerid,215.4959,125.4498,1003.2188) || PlayerToPoint(10, playerid,1564.4706,-1665.4108,28.3956))



Re: Need teleport help. - Frank_Tesla - 01.04.2009

You could either use "or" as pıʞoɹʎd suggested, or use an array and loop through the coordinates like this:

Код:
new ElevatorArray [][3] = {
{1525.4550,-1677.8188,5.8906},
{215.4959,125.4498,1003.2188},
{1564.4706,-1665.4108,28.3956}
};


if(strcmp(cmdtext, "/elevator", true) == 0 || strcmp(cmd, "/ele", true) == 0)
{
  new ElevatorFound = 0;
  for(new i = 0; i < sizeof(ElevatorArray); i ++)
  {
     if(PlayerToPoint(10, playerid,ElevatorArray[i][0] ,ElevatorArray[i][1],ElevatorArray[i][2])
     {
        ElevatorFound = 1;
        // do something
     }
  }
  if(ElevatorFound == 0)
  {
     SendClientMessage(playerid,COLOR_GREY,"You're not at an elevator!");
     return 1;
  }
}



Re: Need teleport help. - faeain - 01.04.2009

Thanks for the help. =)

new problem:
When i teleport from interior 10 to 0 i se no cars or anything, so i have to teleport back to 10 and exit from the door.
Is this something that can be fixed ?
Thanks.


Re: Need teleport help. - Frank_Tesla - 01.04.2009

LinkVehicleToInterior(vehicleid, 0 );

Or you could be describing Virtual Worlds. In which case you have these functions at your disposal:

GetVehicleVirtualWorld(vehicleid);
GetPlayerVirtualWorld(playerid);
SetPlayerVirtualWorld(playerid, 0);
SetVehicleVirtualWorld(vehicleid, 0);



Re: Need teleport help. - faeain - 01.04.2009

and if i would use that how would the code you posted before look like ?
Sry for beeing slow its my 3rd day in the scripting life =)
Thanks.


Re: Need teleport help. - Frank_Tesla - 01.04.2009

You didn't post any code that gives me a clue what's happening in game.


Show me the SetPlayerPos part of it and I may be able to help troubleshoot.


Re: Need teleport help. - faeain - 02.04.2009

Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:current;
  current = GetPlayerMenu(playerid);
  if(current == teleportmenu)
  {
    switch(row)
    {
      case 0:{
        	SetPlayerInterior(playerid,0);
				SetPlayerPos(playerid,1525.4550,-1677.8188,5.8906); //down
      }
      case 1:{
				SetPlayerInterior(playerid,10);
				SetPlayerPos(playerid,215.4959,125.4498,1003.2188); //middle
      }
      case 2:{
				SetPlayerInterior(playerid,0);
				SetPlayerPos(playerid,1564.4706,-1665.4108,28.3956); //up
      }
    }
  }
  return 1;
}