Teleport X Y Z
#1

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
Reply
#2

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
Reply
#3

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.
Reply
#4

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;
}
Reply
#5

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

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

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

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.
Reply
#9

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
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)