The method player.teleport() is used to teleport a player to a specific location within the room. It requires five parameters: the user ID of the player to teleport, and the X, Y, Z coordinates of the destination, along with the facing direction.

We have included some facing directions that can be accessed by importing the class "Facing" from the package. For example:

const { Facing } = require("highrise.sdk");

// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", (user, message) => {
  if (message === "teleport") {
    bot.player.teleport(user.id, 1, 0, 0, Facing.FrontLeft).catch(e => console.error(e));
  }
});

The Highrise.sdk package handles errors directly within the methods themselves. Each method returns a promise, so when using .catch(), it will log any errors that occur. This feature is useful in scenarios such as when a player leaves the room. Here's an example demonstrating this:

// Assuming you have defined the Highrise instance as "bot".
bot.on("chatCreate", (user, message) => {
  if (message === "teleport") {
    bot.player.teleport(user.id, 1, 0, 0, "invalid").catch(e => console.error(e));
  }
});

In this example, we use an invalid facing direction. It should log an error and refrain from executing the method.


Go Back: Perform Actions On Player