ax.character¶
Character management system for creating, storing, and retrieving character data.
Documented functions: 13 · Realm: server, shared
Functions¶
ax.character:CanPopulateVar(varName, payload, client)ax.character:Get(id)ax.character:GetVar(char, name, fallback, dataFallback)ax.character:RegisterVar(name, data)ax.character:SetVar(char, name, value, opts)ax.character:SyncBotToClients(char, recipients)ax.character:ValidateVar(varName, value)ax.character:Create(payload, callback)ax.character:Delete(id, callback)ax.character:Kick(client, reason)ax.character:Load(client, character)ax.character:Restore(client, callback)ax.character:Sync(client, character, recipient)
ax.character:CanPopulateVar(varName, payload, client)¶
Check if a variable can be populated during character creation.
Server-side validation to determine if a variable is available for population.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
varName |
string |
The variable name to check |
payload |
table |
Character creation payload data |
client |
Player |
The client creating the character |
Returns
boolean,: string|nil True if allowed, false if not. Error message if denied.
Usage
Source: gamemode/framework/libraries/sh_character.lua:276
ax.character:Get(id)¶
Get a character by their unique ID.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
id |
number |
The character's unique ID |
Returns
table|nil: The character table if found, nil if invalid ID or not found
Usage
Source: gamemode/framework/libraries/sh_character.lua:27
ax.character:GetVar(char, name, fallback, dataFallback)¶
Get a character variable's value.
Retrieves a character variable with fallback to default or provided fallback value.
For ax.type.data variables, passing fallback reads a nested key and
dataFallback is used when that nested key is absent.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
char |
table |
The character instance |
name |
string |
The variable name to retrieve |
Returns
any: The variable value, default value, or fallback
Usage
Source: gamemode/framework/libraries/sh_character.lua:55
ax.character:RegisterVar(name, data)¶
Register a new character variable.
Creates a character variable with getter/setter methods and database integration.
Automatically generates Get/Set methods unless disabled with bNoGetter/bNoSetter.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
name |
string |
The variable name |
data |
table |
Variable configuration including default, field, fieldType, etc. |
Usage
Source: gamemode/framework/libraries/sh_character.lua:305
ax.character:SetVar(char, name, value, opts)¶
Set a character variable's value.
Updates a character variable and handles networking and change callbacks.
For ax.type.data variables, pass the nested key as value and provide
opts.dataValue for the stored value.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
char |
table |
The character instance |
name |
string |
The variable name to set |
value |
any |
New value, or nested data key for ax.type.data vars |
Usage
Source: gamemode/framework/libraries/sh_character.lua:96
ax.character:SyncBotToClients(char, recipients)¶
Sync a bot character to all clients for variable updates.
Sends bot character data to clients so they can receive variable changes.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
char |
table |
The bot character instance |
recipients |
table |
Optional specific recipients, defaults to all players |
Usage
Source: gamemode/framework/libraries/sh_character.lua:256
ax.character:ValidateVar(varName, value)¶
Verifies the input based on the character variable's validate function, if it exists.
Realm: shared
Parameters
| Name | Type | Description |
|---|---|---|
varName |
string |
The variable name to validate |
value |
any |
The value to validate |
Returns
boolean,: string|nil True if valid, false if not. Error message if invalid.
Usage
Source: gamemode/framework/libraries/sh_character.lua:229
ax.character:Create(payload, callback)¶
Create a new character in the database.
Creates a character with the provided payload data and automatically creates an inventory.
Calls the callback with the character and inventory objects upon completion.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
payload |
table |
Character creation data containing variable values |
callback |
function |
Optional callback function called with (character, inventory) or (false) on failure |
Usage
Source: gamemode/framework/libraries/sv_character.lua:28
ax.character:Delete(id, callback)¶
Delete a character from the database.
Permanently removes a character and its associated inventory from the database.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
id |
number |
The character ID to delete |
callback |
function |
Optional callback function called with success boolean |
Usage
Source: gamemode/framework/libraries/sv_character.lua:327
ax.character:Kick(client, reason)¶
Kick a player out of their active character and return them to the menu.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
client |
Player |
The player to kick out of their character |
reason |
string\|nil |
Optional reason to notify the player with |
Returns
boolean: True if a character was unloaded
Usage
Source: gamemode/framework/libraries/sv_character.lua:214
ax.character:Load(client, character)¶
Load a character for a player.
Associates a character with a player, syncs character data, and sets up inventory.
Automatically respawns the player after loading the character.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
client |
Player |
The player entity to load the character for |
character |
table |
The character object to load |
Usage
Source: gamemode/framework/libraries/sv_character.lua:118
ax.character:Restore(client, callback)¶
Restore all characters for a player from the database.
Loads all characters associated with the player's SteamID64 and sends them to the client.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
client |
Player |
The player entity to restore characters for |
callback |
function |
Optional callback function called with the character array |
Usage
Source: gamemode/framework/libraries/sv_character.lua:263
ax.character:Sync(client, character, recipient)¶
Synchronize character data to all clients or a specific recipient.
Broadcasts character information to all connected players or a specific player for client-side access.
Realm: server
Parameters
| Name | Type | Description |
|---|---|---|
client |
Player |
The player associated with the character |
character |
table |
The character object to synchronize |
recipient |
Player |
Optional specific recipient; if nil, broadcasts to all |
Usage
Source: gamemode/framework/libraries/sv_character.lua:471