#how to add a close chat at custom command script
1 messages · Page 1 of 1 (latest)
import { world } from '@minecraft/server';
world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
switch (eventData.message) {
case '+hub':
eventData.cancel = true;
player.runCommandAsync('tp 0 2 0');
break;
case '+fly':
eventData.cancel = true;
player.runCommandAsync('ability @s mayfly true');
player.runCommandAsync('tellraw @s {"rawtext":[{"text":"successfully!!"}]}');
break;
case '+unfly':
eventData.cancel = true;
player.runCommandAsync('ability @s mayfly false');
break;
case '!gmc':
eventData.cancel = true;
player.runCommandAsync('gamemode c');
break;
case '!gms':
eventData.cancel = true;
player.runCommandAsync('gamemode s');
break;
default: break;
}
});
I just want add a close chat function between these scripts
how to add a close chat at custom command script
Please do not ping mods for add-on support.
Sry
Only ping us if something serious is happening
Ok
You cant close chat using scripts
can use /damage command
Thanks!!
@low plover but it doesn't work
It will still opening chat when get damage
Have another way plz?
can't force close the chat consistently. Damaging work once only.
If you're not opening any server form, it shouldn't be a problem.
But I tried damage ,it dont work
I don't really see a need to close the chat window. The user can just close it willingly and it has no impact based on your code.
you need gamemode survival to get hurt damage
I alr is survival mode but when I got damage it will still opening