SA-MP Forums Archive
Teleport X Y Z - 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: Teleport X Y Z (/showthread.php?tid=84314)



Teleport X Y Z - anumaz - 30.06.2009

Hey, I'm new in scripting and I wanna create a command that teleport me to the X Y Z locations gave.

Command: /gotoloc (x) (y) (z)

and then it teleports me to this locations.

I really have NO IDEA on how to do this, and I didn't find any related topics to this.

Thanks for helping me


Re: Teleport X Y Z - *ToM* - 30.06.2009

pawn Код:
if(strcmp(cmdtext, "/gotoloc", true) == 0)
    {
      SetPlayerPos(playerid, x y z coords);
      SetPlayerInterior(playerid, 0); // 0 if it's outside, otherwise change it to interior id
      return 1;
     }
Put it OnPlayerCommandText callback



Re: Teleport X Y Z - anumaz - 30.06.2009

No you don't get it lol

InGame, I type, in exemple: /gotoloc 3228,33 5392,77 10,923

Then, it TPs me to this location.


Re: Teleport X Y Z - Grim_ - 30.06.2009

Untested
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  dcmd(gotoxyz, 7, cmdtext);
  return 0;
}

dcmd_gotoxyz(playerid, params[])
{
  new Float:x, Float:y, Float:z;
  if(sscanf(params, "fff", x, y, z)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /gotoxyz <x> <y> <z>");
  else
  {
   SetPlayerPos(playerid, x, y, z);
   SendClientMessage(playerid, 0xFF0000AA, "Warped to your desired position!");
  }
  return 1;
}



Re: Teleport X Y Z - anumaz - 30.06.2009

Aight, thanks, I'll try it tomorrow because now I g2g to sleep. Thanks for helping though


Re: Teleport X Y Z - Grim_ - 30.06.2009

Quote:
Originally Posted by anumaz
Aight, thanks, I'll try it tomorrow because now I g2g to sleep. Thanks for helping though
No problem


Re: Teleport X Y Z - Ignas1337 - 30.06.2009

this should really work, although I was going to give you a strtok example... hmm...


Re: Teleport X Y Z - Grim_ - 30.06.2009

Quote:
Originally Posted by Thanatos
this should really work, although I was going to give you a strtok example... hmm...
The strtok example would take awhile since you'd need to use strtok 3 times. That's why I used sscanf instead.
Also, what was the point of that post? He seemed happy he got a workign command.


Re: Teleport X Y Z - Ignas1337 - 30.06.2009

oh well, the point of a post was to express myself. anyway yeah sscanf is faster, never had any practice with it though. i'm gonna check it out


Re: Teleport X Y Z - Grim_ - 30.06.2009

Quote:
Originally Posted by Thanatos
oh well, the point of a post was to express myself. anyway yeah sscanf is faster, never had any practice with it though. i'm gonna check it out
yeah, I'm new to it aswell. I'm starting to mess aroudn with it since its faster and is much easier than strtok.