Class¶
Character class helpers for registering, loading, retrieving, counting, validating, and resolving playable classes.
Overview
lia.class.getBodygroups(class)View Source
Purpose
Retrieves the normalized bodygroup table configured for a class.
Realm
Shared
Parameters
table|number|string class Class data table or class identifier used to look up registered class data.
Returns
table Normalized bodygroup values from `bodyGroups` or `bodygroups`, or an empty table when no class data exists.
Example Usage
local bodygroups = lia.class.getBodygroups(CLASS_CITIZEN)
lia.class.getMergedBodygroups(character)View Source
Purpose
Builds the effective bodygroup table for a character by combining class defaults with character-specific overrides.
Realm
Shared
Parameters
Character character Character whose class bodygroups and stored bodygroup overrides should be merged.
Returns
table Merged normalized bodygroup table where character overrides take priority over class defaults.
Example Usage
local bodygroups = lia.class.getMergedBodygroups(character)
lia.class.register(uniqueID, data)View Source
Purpose
Registers or updates a character class with a unique identifier and class data.
Realm
Shared
Parameters
string uniqueID Unique string identifier for the class.
table data Class definition data to store, including a valid `faction` value and optional class configuration.
Returns
number|nil Registered class index, or nil if registration fails because the class has no valid faction. table|nil Registered class table, or nil if registration fails because the class has no valid faction.
Example Usage
local classIndex = lia.class.register("medic", {
name = "Medic",
desc = "A trained field medic.",
faction = FACTION_CITIZEN
})
lia.class.loadFromDir(directory)View Source
lia.class.canBe(client, class)View Source
Purpose
Checks whether a player is allowed to join a specific class.
Realm
Shared
Parameters
Returns
boolean True if the player can join the class, otherwise false. string|nil Localized failure reason when class validation fails.
Example Usage
local canJoin, reason = lia.class.canBe(client, CLASS_MEDIC)
lia.class.get(identifier)View Source
Purpose
Retrieves registered class data by identifier.
Realm
Shared
Parameters
number|string identifier Class list key used to retrieve the class data.
Returns
table|nil Registered class data when found, otherwise nil.
Example Usage
local classData = lia.class.get(CLASS_MEDIC)
lia.class.getPlayers(class)View Source
lia.class.getPlayerCount(class)View Source
lia.class.retrieveClass(class)View Source
Purpose
Finds a registered class index by matching a class unique ID or display name.
Realm
Shared
Parameters
string class Class unique ID or class name to search for.
Returns
number|nil Matching class index when found, otherwise nil.
Example Usage
local classIndex = lia.class.retrieveClass("medic")
lia.class.hasWhitelist(class)View Source
Purpose
Checks whether a class requires whitelist access.
Realm
Shared
Parameters
number class Class index to check.
Returns
boolean True if the class requires whitelist access, otherwise false.
Example Usage
if lia.class.hasWhitelist(CLASS_MEDIC) then
client:notifyInfo("This class requires whitelist access.")
end
lia.class.retrieveJoinable(client)View Source
Purpose
Returns classes that a player is currently eligible to join.
Realm
Shared
Parameters
Player client optional Player to check. Defaults to the local player on the client when omitted.
Returns
table Sequential table of class data tables that the player can join.
Example Usage
local classes = lia.class.retrieveJoinable(client)
Hooks
Library-specific hooks documented for this library.
CanPlayerJoinClass(client, class, classData)View Source
Purpose
Allows plugins or modules to block a player from joining a class during class eligibility checks.
Realm
Shared
Parameters
Player client The player attempting to join the class.
number class The class index being checked.
table classData The registered class data for the class being checked.
Returns
boolean|nil Return false to prevent the player from joining the class. Return nil or any non-false value to continue normal class validation.