Console and chat commands, with arguments delivered as a real Haxe Array<String> rather than a raw Lua table.

Commands.register("givecash", (source, args) -> {
    var amount = Commands.intArg(args, 0, 100);
    grantCash(source, amount);
}, "group.admin");

On the server source is the player who ran the command, or 0 for the console. On the client it is always 0.

Static methods

@:value({ fallback : null })staticinlinearg(args:Array<String>, index:Int, ?fallback:String):String

Reads argument index, falling back to fallback when it is missing.

staticinlineexecute(commandString:String):Void

Runs a command as if typed into the console.

@:value({ fallback : 0 })staticfloatArg(args:Array<String>, index:Int, fallback:Float = 0):Float

Reads argument index as a float, falling back when missing or unparseable.

@:value({ fallback : 0 })staticintArg(args:Array<String>, index:Int, fallback:Int = 0):Int

Reads argument index as an integer, falling back when missing or unparseable.

staticinlineisAceAllowed(principal:String, object:String):Bool

Whether principal (an identifier, group.x, or player.x) is allowed to perform object. Server-side ACE checks only.

staticregister(name:String, handler:(source:Int, args:Array<String>) ‑> Void, ?aceObject:String):Void

Registers a command.

Parameters:

name

The command, without a leading /.

handler

Receives the invoking player and the parsed arguments.

aceObject

When set, the command is registered as restricted and only principals granted this ACE object may run it (e.g. "group.admin", or "command.givecash"). Leave null for an unrestricted command.

staticregisterRaw(name:String, handler:(source:Int, args:Array<String>, rawCommand:String) ‑> Void, ?aceObject:String):Void

Registers a command whose handler also receives the raw, unparsed command line — needed when an argument may contain spaces.

@:value({ index : 0 })staticrestArg(args:Array<String>, index:Int = 0):String

Joins every argument from index onwards back into one string.