#would this work for commands?

1 messages · Page 1 of 1 (latest)

limpid tulip
#
import { world } from "@minecraft/server"

world.events.beforeChat.subscribe((data) => {
    const player = data.sender;
    const message = data.message;
    if (message.startsWith(prefix)) {
        data.cancel = true;
        const message2 = player.message2().find(m => m.startsWith(prefix));
        const [command, arg1, arg2] = message2?.split(' ') ?? []
        if (command == 'warp') {
            if (arg1 == 'spawn') {
                player.runCommandAsync("tp @s [spawn coordinates]");
                player.sendMessage("Teleported to Spawn");
                player.runCommandAsync("gamemode a");
            }
            if (arg1 == 'shop') {
                player.runCommandAsync("tp @s [shop coordinates]");
                player.sendMessage("Teleported to Shop");
                player.runCommandAsync("gamemode a");
            }
            if (arg1 == 'parkour') {
                player.runCommandAsync("tp @s [parkour coordinates]");
                player.sendMessage("Teleported to Parkour");
                player.runCommandAsync("gamemode a");
            }
        }
    } else {
        data.cancel = false;
    }
})
#

@wheat wasp

wheat wasp
#

Use object

#

Or teleport them right away, instead of tagging the sender

limpid tulip
#

ok

#

@wheat wasp how do i use player.teleport