world.beforeEvents.chatSend.subscribe((eventData) => {
const player = eventData.sender;
switch (eventData.message) {
case '!gmc':
eventData.cancel = true;
player.runCommandAsync('gamemode c');
break;
case '!gms':
eventData.cancel = true;
player.runCommandAsync('gamemode s');
break;
default: break;
}
});```
#chat command sample pack not working
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 '!gmc':
eventData.cancel = true;
player.runCommandAsync('gamemode c');
break;
case '!gms':
eventData.cancel = true;
player.runCommandAsync('gamemode s');
break;
default: break;
}
});```
sys.run
How is this different?
The code seems valid. It's probably manifest issue
"format_version": 2,
"header": {
"description": "new survival cosmic pack.",
"name": "§l§fCosmic §r§b[v.8.6]",
"uuid": "6a513b98-780d-45fd-9c53-070e8867d7ed",
"version": [ 0, 8, 6],
"min_engine_version": [ 1, 19, 73 ]
},
"modules": [
{
"description": "§r",
"type": "data",
"uuid": "c57e642c-2e2d-4f19-a80b-9fc9991742ef",
"version": [1, 0, 0 ]
}
]
},
{
"description": "Gametest Module",
"type": "script",
"language": "javascript",
"entry": "scripts/index.js",
"uuid": "f626740d-50a6-49f1-a24a-834983b72134",
"version": [1, 0, 0]
}
],
"dependencies": [
{
// Minecraft native module - needed to use the "@minecraft/server" module
"module_name": "@minecraft/server",
"version": "1.6.0-beta"
}
]
}```
What version is your Minecraft?
is your script file named index? and have the correct file path?
In the latest version, you should go with 1.7.0-beta.
Turn on the content log to debug your code, this includes your manifest error.
All is fine on that end I’ll change version
[Localization][warning]-Line: 2 - Invalid lang file format. New line character was found while parsing key: '#'.
Is the only major error I get when launching
Unrelated I think tho
No luck and no script or manifest errors
send pack here
@west flint Do what Gega says and use version 1.7.0-beta, and try this:
world.beforeEvents.chatSend.subscribe((event) => {
const { message, sender } = event;
const { dimension } = sender;
if (message === "!gmc") {
const player = event.sender;
event.cancel = true;
player.runCommandAsync(`/gamemode c`);
} else if (message === "!gms") {
const player = event.sender;
event.cancel = true;
player.runCommandAsync(`/gamemode s`);
}
});```
Again how is this any different to what im currently using 🤣💀
It's not, but you do need to change your manifest to target 1.7.0-beta. The one you are trying to target doesn't exist anymore. Also make sure you enable Beta API in your world.
Additionally, in your manifest where you have information for the module type "script" you list the version as [1, 0, 0]. It's actually [0, 0, 1].
I would also suggest that you increase min_engine_version to prevent the pack from being installed on an older, incompatible, version of Minecraft.
Thank you some real help I was looking for appreciate it a ton