Skip to content

ax.player

Player management system for creating, storing, and retrieving player data.

Documented functions: 3  ·  Realm: shared

Functions


ax.player:GetVar(client, key, fallback, dataFallback)

Get a player variable's value.

Retrieves a player variable with fallback to default or provided fallback value.

Realm: shared

Parameters

Name Type Description
client Player The player entity
key string The variable name to retrieve
fallback any Optional fallback value if variable is not set

Returns

  • any: The variable value, default value, or fallback

Usage

local data = ax.player:GetVar(player, "customData", "default")

Source: gamemode/framework/libraries/sh_player.lua:29


ax.player:RegisterVar(key, data)

Register a new player variable.

Creates a player variable with getter/setter methods and database integration.

Automatically generates Get/Set methods unless disabled with bNoGetter/bNoSetter.

Realm: shared

Parameters

Name Type Description
key string The variable name
data table Variable configuration including default, field, fieldType, etc.

Usage

ax.player:RegisterVar("customData", {default = "", fieldType = ax.type.text})

Source: gamemode/framework/libraries/sh_player.lua:195


ax.player:SetVar(client, key, value, opts)

Set a player variable's value.

Updates a player variable and handles networking and change callbacks.

Realm: shared

Parameters

Name Type Description
client Player The player entity
key string The variable name to set
value any The new value to set
opts table\|nil Optional options: bNoNetworking, recipients, bNoDBUpdate

Usage

ax.player:SetVar(player, "customData", "new value", {bNoDBUpdate = true})
ax.player:SetVar(player, "data", "flags", {dataValue = "ab", bNoNetworking = true})

Source: gamemode/framework/libraries/sh_player.lua:69