From 75808494460fb0924ae287f7e876c2fef11981fa Mon Sep 17 00:00:00 2001 From: Picoseconds Date: Wed, 5 Aug 2020 19:00:06 -0600 Subject: [PATCH] feat: added /tp command to teleport to another player --- src/console.ts | 23 +++++++++++++++++++++++ src/moomoo/Game.ts | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/console.ts b/src/console.ts index 64639eb..10e8ccd 100755 --- a/src/console.ts +++ b/src/console.ts @@ -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) => { diff --git a/src/moomoo/Game.ts b/src/moomoo/Game.ts index c1b84c3..44d187a 100755 --- a/src/moomoo/Game.ts +++ b/src/moomoo/Game.ts @@ -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]])