A way to add aliases from a function.
LadyCailinBot opened this issue ยท 7 comments
CMDHELPER-3058 - Reported by Hazae41
For example:
/bind = >>>
add_alias(
/whatsup = >>>
broadcast('Whats up?')
<<<
)
<<<
Comment by LadyCailin
This is already possible. register_command() is the function you're looking for.
Comment by PseudoKnight
For dynamic commands you can also bind player_command. It depends on what you're doing.
Comment by Hazae41
@LadyCailin How to do my example using register_command() ?
Comment by PseudoKnight
Here's an example:
/bind = >>>
register_command('whatsup', array(
'description': 'Broadcasts "Whats up?"',
'executor': closure(){
broadcast('Whats up?')
}
));
<<<
Comment by Hazae41
and if I want to do:
add_alias(
/whatsup [$player] = >>>
if($player == '',
broadcast('Whats up?')
,
tmsg($player, 'Whats up?')
)
<<<
)
<<<```
Comment by PseudoKnight
This series of questions could be endless. I'd suggest you look at the register_command() docs and infer from here.
/bind = >>>
register_command('whatsup', array(
'description': 'Broadcasts "Whats up?"',
'executor': closure(@alias, @sender, @args, @info) {
if(array_size(@args) < 1) {
broadcast('Whats up?');
} else {
tmsg(@args[0], 'Whats up?');
}
}
));
<<<