#Custom command with /give and codes

1 messages · Page 1 of 1 (latest)

mint flicker
#

totally possible

#

initEvent.customCommandRegistry.registerCommand(
{
name: "naz:code",
description: "enter a code!",
permissionLevel: 1,
mandatoryParameters: [
{
name: "code",
type: mc.CustomCommandParamType.Integer
}],
optionalParameters: []
},
(origin, args) => {
mc.system.run(() => {
let player = origin.sourceEntity
if (args == 676767) {
if (mc.world.getDynamicProperty('676767') == true) {
player.sendMessage('The code 676767 has already been used.')
} else {
mc.world.setDynamicProperty('676767', true)

                    player.sendMessage('You have redeemed the code 676767')
                    // give the player stuff here
                }
            }
        });
    }
);
#

just add multiple

#

and change the name

mint flicker
#

forgot to mention put this in start up

vapid bough
#

And How can i set the dynamic properties and the other codes?

#

Do i need to import something to the code to work?

#

And for giving a shulker box can i use like, structure block and Destroy?

#

I know that i can do this but idk how 😭

#

And what version of @minecraft/server do you use um manifest.json?

#

2.4.0 or 2.3.0

#

Sorry for too many questions 😭

vapid bough
#

And, for every single code Would I have to rewrite this entire code?

#

Isn't there a way to create another JavaScript file with the code and import it?

mint flicker
#

2.5.0