Skip to main content

register

Registers a command or an action.

In Verza, commands and actions serve different purposes. Commands are executed by players, while actions are used to check script permissions.

To register an action, use the + prefix.

Learn more on Roles and Permissions.

Syntax

engine.commands.register(commandOrAction);

Parameters

NameTypeDescription
commandOrActionCommandThe command or the action to register.

Example

// without parameters
const command = new Command('sayhi').on(player => {
player.sendMessage('Hi!');
});

engine.commands.register(command);

// with parameters
const command = new Command('sayhi', [
new CommandParam('name', 'string').withDisplay('The name of the player'),
]).on((player, {name}) => {
player.sendMessage(`Hi ${name}!`);
});

engine.commands.register(command);

// as an action
const action = new Command('+super_power');

engine.commands.register(command);

// log permissions
console.log(
'sayhi',
engine.localPlayer.hasAccess('sayhi'),

'+super_power',
engine.localPlayer.hasAccess('+super_power'),
);

Available on: Client Server