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;
}
})
#would this work for commands?
1 messages · Page 1 of 1 (latest)