class Commands
package fivem.shared.core
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
staticinlinearg(args:Array<String>, index:Int, ?fallback:String):String
Reads argument index, falling back to fallback when it is missing.
staticfloatArg(args:Array<String>, index:Int, fallback:Float = 0):Float
Reads argument index as a float, falling back when missing or unparseable.
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.
|
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.
staticrestArg(args:Array<String>, index:Int = 0):String
Joins every argument from index onwards back into one string.