Skip to content

ax.class

Source: gamemode/framework/libraries/sh_class.lua

Class management system for creating, storing, and retrieving class data.

Documented functions: 7

Functions


ax.class:CanBecome(class, client)

Check if a player can become a specific class. Runs through hook validation and class-specific CanBecome functions.

Realm: shared

Parameters

Name Type Description
class string\|number The class ID, index, or name
client Player The player entity to check permissions for

Returns

  • boolean,: string|nil True if allowed, false if not. Error message if denied.

Usage

local canBecome, reason = ax.class:CanBecome("security", player)

ax.class:Get(identifier)

Get a class by its identifier. Supports lookup by unique ID string, index number, name, or partial name matching.

Realm: shared

Parameters

Name Type Description
identifier string\|number The class ID, index, or name to search for

Returns

  • table|nil: The class table if found, nil otherwise

Usage

local class = ax.class:Get("security")
local class = ax.class:Get(1)

ax.class:GetAll(filter)

Get all loaded class instances. Returns the loaded class list, optionally filtered by faction or fuzzy name.

Realm: shared

Returns

  • table: Array of all class instances

Usage

local allClasses = ax.class:GetAll()
local cityClasses = ax.class:GetAll({ faction = FACTION_CITIZEN })
local securityMatches = ax.class:GetAll({ name = "security" })

ax.class:HasAny(class, classes)

Check if a class matches any in a list of classes. Used for validating if a class belongs to a set of allowed classes.

Realm: shared

Parameters

Name Type Description
class string\|number The class identifier to check
classes table Array of class identifiers to compare against

Returns

  • boolean: True if the class matches any in the list, false otherwise

Usage

if ax.class:HasAny(playerClass, {CLASS_SECURITY, CLASS_SCIENTIST}) then print("Player is security or scientist") end

ax.class:Include(directory, timeFilter)

Include and load class files from a directory. Recursively searches for class .lua files and loads them into the class system. Automatically handles shared/client/server file prefixes.

Realm: shared

Parameters

Name Type Description
directory string The directory path to search for class files

Returns

  • boolean: True if the operation completed successfully, false on error

Usage

ax.class:Include("parallax/gamemode/classes")

ax.class:Initialize()

Initialize the class system by loading all class files. Automatically includes classes from framework, modules, and schema directories. Called during framework boot to set up all available classes.

Realm: shared

Usage

ax.class:Initialize()

ax.class:IsValid(class)

Check if a class exists and is valid. Validates class existence by attempting to retrieve it.

Realm: shared

Parameters

Name Type Description
class string\|number The class identifier to validate

Returns

  • boolean: True if the class exists, false otherwise

Usage

if ax.class:IsValid("security") then print("Class exists") end