Skip to content

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)

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:Add("test", { description = "Test command", OnRun = function(client) end })

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

local values, err = ax.command:ExtractArgs(def, "player1 hello world")

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

local def = ax.command:Find("pm")
local def = ax.command:Find("private", false, true)

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

local matches = ax.command:FindAll("pm")

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

local command = ax.command:FindClosest("test")

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

local allCommands = ax.command:GetAll()

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

local canRun, reason = ax.command:HasAccess(client, def)

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

local help = ax.command:Help("pm")

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

local name, rawArgs = ax.command:Parse("/pm player1 hello")

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

local ok, result = ax.command:Run(client, "pm", "player1 hello")

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

ax.command:Send("/pm player1 hello")