Skip to content

Commit

Permalink
feat: added /tp command to teleport to another player
Browse files Browse the repository at this point in the history
  • Loading branch information
Picoseconds committed Aug 6, 2020
1 parent ae7b958 commit 7580849
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,29 @@ dispatcher.register(
)
);

dispatcher.register(
literal("tp").then(
argument("playerSID", integer()).executes((context) => {
let playerSID = context.getArgument("playerSID", Number);
let thisPlayer = context.getSource() as Player;
let game = getGame();

if (game) {
let player = game.state.players.find(
(player) => player.id == playerSID
);

if (player) {
thisPlayer.location = player.location.add(0, 0, true);
game.sendGameObjects(thisPlayer);
}
}

return 0;
})
)
);

dispatcher.register(
literal("ban").then(
argument("playerSID", integer()).executes((context) => {
Expand Down
2 changes: 1 addition & 1 deletion src/moomoo/Game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ export default class Game {
}

if (packet.data[0].startsWith("/") && client.admin) {
console.runCommand(packet.data[0].substring(1))
console.runCommand(packet.data[0].substring(1), client.player || undefined);
} else {
let chatPacket = packetFactory.serializePacket(
new Packet(PacketType.CHAT, [client.player?.id, packet.data[0]])
Expand Down

0 comments on commit 7580849

Please sign in to comment.