Commands API

CommandPermissonLevel

Enumchar value
Any0
GameMasters1
Admin2
HostPlayer3
Console4
Internal5

CommandFlagValue

Enumunsigned short
None0x00
Usage0x01
Visibility20x02
Visibility40x04
Visibility60x06
Visibility80x08
Sync0x10
Execute0x20
Type0x40
Cheat0x80
Async0x100

Dynamic commands

DynamicCommand::setup("hello", "Hello world command", {}, {}, { {}, }, [](DynamicCommand const& command, CommandOrigin const& origin, CommandOutput& output, std::unordered_map<std::string, DynamicCommand::Result>& results) {
  // Do something
  output.success("Hello world!"); // Command successfyl output
}, CommandPermissionLevel::Any);

Command by class

class HelloWorldCommand : public Command {

public:
  void execute(CommandOrigin const& ori, CommandOutput& output) const override {
    // Do something
    output.success("Hello world!"); // Command successfyl output
  }

  static void setup(CommandRegistry* registry) {
    registry->registerCommand(
      "hello",               // Name
      "Hello world command", // Description
      CommandPermissionLevel::Any,
      {(CommandFlagValue)0},
      {(CommandFlagValue)0x80}
    );
    registry->registerOverload<HelloWorldCommand>("hello"); // Name
  }
};
void RegisterCommands() {
  Event::RegCmdEvent::subscribe([](Event::RegCmdEvent event) {
    HelloWorldCommand::setup(event.mCommandRegistry); // Setup command by class
    return true;
  });
}
Last Updated:
Contributors: VinkyV