#how to make commands with a prefix like "//"

1 messages · Page 1 of 1 (latest)

hasty hawk
#

Huh? What do you mean by "prefix command"?

#

?custom command

severe vergeBOT
#
Can you detect chat?

From bedrock 1.17.30 stable and upper we are now able to read/modify/cancel the in-game chat with Gametest-API so custom commands are possible!

hasty hawk
#

If you're completely new, read wiki

idle meadow
#

you can't make custom / commands yet

#

you can make // though

hasty hawk
#

Read the link I send

#

It has an example

#

It just an example, of course. You just have to explore scripting

#

Read documentation

#

Get the player name by using .name

#

Look at wiki, it start with !

You just simply replaced it with //

That's why I'm telling you to read.

agile mulch
#

import { world } from '@minecraft/server'

world.beforeEvents.chatSend.subscribe((data) => {
  const prefix = '+';
  const player = data.sender;
  const message = data.message.toLowerCase();
  const args = message.slice(prefix.length).split(new RegExp(/\s+/g));
  const cmd = args.shift();
  if (!message.startsWith(prefix)) return;
  data.cancel = true;
  switch (cmd) {
    case 'gmc':
      player.runCommandAsync('gamemode c')
      break;
    case 'gms':
      player.runCommandAsync('gamemode s')
      break;
    default:
      player.sendMessage('Invalid cmd!')
      break;
  }
})```
#

Is that what you wanted?

tranquil crow
#

/ will not work

#

u have to use a different character

#

nope