ax.command¶
Source: gamemode/framework/libraries/sh_command.lua
Command system for registering and executing chat/console commands.
Documented functions: 12
Functions¶
ax.command:Add(name, def)ax.command:ConvertArgument(value, argDef)ax.command:ExtractArgs(def, raw)ax.command:Find(look, bCaseSensitive, bExact)ax.command:FindAll(partial)ax.command:FindClosest(partial)ax.command:GetAll()ax.command:HasAccess(caller, def)ax.command:Help(name)ax.command:Parse(text)ax.command:Run(caller, name, rawArgs)ax.command:Send(text)
ax.command:Add(name, def)¶
Register a command with the system. Creates a new command with validation, permissions, and automatic CAMI integration.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The command name (will be normalized) |
def |
table |
Command definition with OnRun, description, arguments, etc. |
Usage
ax.command:ConvertArgument(value, argDef)¶
Convert and validate a single argument value.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
string |
value |
The raw string value |
table |
argDef |
The argument definition |
Returns
any|nil,: string Converted value or nil with error
ax.command:ExtractArgs(def, raw)¶
Extract and validate arguments from raw input string. Parses command arguments according to type definitions and validates them.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
def |
table |
Command definition containing argument specifications |
raw |
string |
Raw argument string from user input |
Returns
table|nil,: string Parsed values or nil with error message
Usage
ax.command:Find(look, bCaseSensitive, bExact)¶
Find a command definition by name or alias. Supports exact or partial matching and optional case sensitivity. Returns the first matching definition in the registry.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
look |
string |
Text to search for (command name or alias) |
Returns
table|nil: Command definition if found
Usage
ax.command:FindAll(partial)¶
Find all commands matching a partial name or alias. Performs case-insensitive search for commands starting with the partial string.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
partial |
string |
The partial string to search for |
Returns
table: Table of matching commands {name = def}
Usage
ax.command:FindClosest(partial)¶
Find the closest single possible command match. Returns the best matching command when multiple partial matches exist.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
partial |
string |
The partial command name to search for |
Returns
table|nil: The closest matching command definition or nil if not found
Usage
ax.command:GetAll()¶
Get all registered commands. Returns the complete registry of all commands and their definitions.
Realm: shared
Returns
table: Table containing all command definitions
Usage
ax.command:HasAccess(caller, def)¶
Check if a caller has access to run a command. Validates permissions through admin checks, custom functions, and CAMI integration.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
caller |
Entity |
The player or console (nil) attempting to run the command |
def |
table |
The command definition |
Returns
boolean,: string Whether access is granted and optional reason
Usage
ax.command:Help(name)¶
Generate a help string for a command.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
string |
name |
The command name |
Returns
string: Help text
Usage
ax.command:Parse(text)¶
Parse command text into name and raw arguments.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
string |
text |
The full command text |
Returns
string|nil,: string Command name and raw arguments
Usage
ax.command:Run(caller, name, rawArgs)¶
Run a command with the given caller and arguments.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
Entity |
caller |
The player or console attempting to run the command |
string |
name |
The command name |
string |
rawArgs |
Raw argument string |
Returns
bool: string Success status and result/error message
Usage
ax.command:Send(text)¶
Send a command from client to server for execution.
Realm: client
Parameters
| Name | Type | Description |
|---|---|---|
string |
text |
The full command text |
Usage