API Reference¶
Complete reference for all Parallax Framework functions and methods.
Table of Contents¶
ax.hookax.factionax.itemax.characterax.inventoryax.commandax.netax.configax.utilax.database
ax.hook¶
ax.hook:Register(name)¶
Register a new hook type, this allows to create groups of hook families.
For example, registering SCHEMA allows to create hooks like SCHEMA:PlayerSpawn or SCHEMA:CharacterCreated. This is purely organizational and has no functional effect other than grouping hooks together. You can also create custom hook types for your own systems, for example INVENTORY for inventory-related hooks or FACTION for faction-related hooks.
SCHEMA is automatically registered by the framework, so you don't need to register it manually unless you want to, if you do register it manually it will just be ignored since it already exists.
Parameters:
name(string): Hook type name
Returns:
- None
Example:
ax.faction¶
ax.faction:Get(identifier)¶
Get faction by ID, index, or name.
Parameters:
identifier(string|number): Faction identifier
Returns:
- (table|nil): Faction table or nil
Example:
ax.faction:CanBecome(identifier, client)¶
Check if player can join faction.
Parameters:
identifier(string|number): Faction identifierclient(Player): Player entity
Returns:
- (boolean): Can join
- (string|nil): Reason if denied
Example:
local canJoin, reason = ax.faction:CanBecome("citizen", client)
if !canJoin then
client:Notify(reason)
end
ax.faction:GetAll()¶
Get all factions.
Parameters:
- None
Returns:
- (table): Table of all factions
Example:
local factions = ax.faction:GetAll()
for id, faction in pairs(factions) do
print(id, faction.name)
end
ax.faction:IsValid(identifier)¶
Check if faction exists.
Parameters:
identifier(string|number): Faction identifier
Returns:
- (boolean): Faction exists
Example:
ax.item¶
ax.item:Get(identifier)¶
Get item definition or instance.
Parameters:
identifier(string|number): Item class or instance ID
Returns:
- (table|nil): Item definition/instance or nil
Example:
ax.item:Spawn(class, position, angle, callback)¶
Spawn item in world (server).
Parameters:
class(string): Item classposition(Vector): Spawn positionangle(Angle): Spawn anglecallback(function): Completion callback
Returns:
- None
Example:
ax.item:Spawn("pistol", Vector(0, 0, 0), Angle(0, 0, 0), function(entity, itemObj)
print("Spawned item:", itemObj.id)
end)
ax.item:Transfer(item, fromInv, toInv, callback)¶
Transfer item between inventories.
Parameters:
item(table): Item instancefromInv(table|number): Source inventorytoInv(table|number): Destination inventorycallback(function): Completion callback
Returns:
- (boolean): Success
- (string|nil): Error message
Example:
local success, reason = ax.item:Transfer(item, playerInv, 0, function(success)
if success then
print("Item dropped")
end
end)
ax.item:GetActionsForClass(class)¶
Get actions for item class.
Parameters:
class(string): Item class
Returns:
- (table): Table of actions
Example:
local actions = ax.item:GetActionsForClass("pistol")
for name, action in pairs(actions) do
print(name, action.name)
end
ax.character¶
ax.character:Get(id)¶
Get character by ID.
Parameters:
id(number): Character ID
Returns:
- (table|nil): Character table or nil
Example:
ax.character:RegisterVar(name, data)¶
Register a character variable.
Parameters:
name(string): Variable namedata(table): Variable configuration
Returns:
- None
Example:
Character Methods¶
character:GetID()¶
Get character ID.
Returns:
- (number): Character ID
character:GetName()¶
Get character name.
Returns:
- (string): Character name
character:SetName(name, options)¶
Set character name.
Parameters:
name(string): New nameoptions(table): Options (bNoNetworking, bNoDBUpdate, recipients)
Returns:
- None
character:GetDescription(fallback)¶
Get character description.
Parameters:
fallback(string): Fallback value
Returns:
- (string): Character description
character:SetDescription(description, options)¶
Set character description.
Parameters:
description(string): New descriptionoptions(table): Options
Returns:
- None
character:GetFaction()¶
Get character faction ID.
Returns:
- (number): Faction ID
character:SetFaction(faction, options)¶
Set character faction.
Parameters:
faction(number): Faction IDoptions(table): Options
Returns:
- None
character:GetInventoryID()¶
Get character inventory ID.
Returns:
- (number): Inventory ID
character:GetOwner()¶
Get player who owns character.
Returns:
- (Player): Player entity
character:GetVar(name, fallback)¶
Get character variable.
Parameters:
name(string): Variable namefallback(any): Fallback value
Returns:
- (any): Variable value
character:SetVar(name, value, options)¶
Set character variable.
Parameters:
name(string): Variable namevalue(any): Variable valueoptions(table): Options
Returns:
- None
ax.inventory¶
ax.inventory:Get(id)¶
Get inventory by ID.
Parameters:
id(number): Inventory ID
Returns:
- (table|nil): Inventory table or nil
Example:
ax.inventory:Create(data, callback)¶
Create new inventory (server).
Parameters:
data(table): Inventory propertiescallback(function): Completion callback
Returns:
- None
Example:
ax.inventory:Create({maxWeight = 50}, function(inventory)
print("Created inventory:", inventory.id)
end)
Inventory Methods¶
inventory:GetID()¶
Get inventory ID.
Returns:
- (number): Inventory ID
inventory:GetWeight()¶
Get current weight.
Returns:
- (number): Weight in kg
inventory:GetMaxWeight()¶
Get maximum weight.
Returns:
- (number): Maximum weight in kg
inventory:AddItem(class, data, callback)¶
Add item to inventory.
Parameters:
class(string): Item classdata(table): Item datacallback(function): Completion callback
Returns:
- (boolean): Success
- (string|nil): Error message
inventory:RemoveItem(itemID)¶
Remove item from inventory.
Parameters:
itemID(number): Item ID
Returns:
- (boolean): Success
- (string|nil): Error message
inventory:HasReceiver(client)¶
Check if client can see inventory.
Parameters:
client(Player): Player entity
Returns:
- (boolean): Client can see inventory
inventory:AddReceiver(client)¶
Add receiver to inventory.
Parameters:
client(Player): Player entity
Returns:
- None
inventory:RemoveReceiver(client)¶
Remove receiver from inventory.
Parameters:
client(Player): Player entity
Returns:
- None
inventory:GetReceivers()¶
Get all receivers.
Returns:
- (table): Table of players
ax.command¶
ax.command:Add(name, def)¶
Register a new command.
Parameters:
name(string): Command namedef(table): Command definition
Returns:
- None
Example:
ax.command:Add("test", {
description = "Test command",
OnRun = function(this, client)
return true
end
})
ax.command:Run(caller, name, rawArgs)¶
Execute a command.
Parameters:
caller(Entity): Player or consolename(string): Command namerawArgs(string): Raw argument string
Returns:
- (boolean): Success
- (string): Result/error message
Example:
ax.command:Find(name)¶
Find command by name.
Parameters:
name(string): Command name
Returns:
- (table|nil): Command table or nil
ax.command:FindAll(name)¶
Find all matching commands.
Parameters:
name(string): Partial command name
Returns:
- (table): Table of matching commands
ax.command:FindClosest(name)¶
Get closest matching command.
Parameters:
name(string): Partial command name
Returns:
- (table|nil): Command table or nil
ax.command:HasAccess(client, command)¶
Check if client can use command.
Parameters:
client(Player): Player entitycommand(table): Command table
Returns:
- (boolean): Can use
- (string|nil): Reason if denied
ax.command:GetAll()¶
Get all commands.
Returns:
- (table): Table of all commands
ax.command:Help(name)¶
Generate help string for command.
Parameters:
name(string): Command name
Returns:
- (string): Help string
Example:
ax.net¶
ax.net:Start(recipients, message, ...)¶
Start network message (server).
Parameters:
recipients(nil|Player|table|Vector): Recipients (nil = all)message(string): Message name...(any): Message data
Returns:
- None
Example:
-- Send to all clients
ax.net:Start(nil, "my_message", data1, data2)
-- Send to specific player
ax.net:Start(client, "my_message", arg1, arg2)
-- Send to players in PVS
ax.net:StartPVS(position, "my_message", arg1, arg2)
-- Send to multiple players
ax.net:Start({client1, client2}, "my_message", arg1, arg2)
ax.net:Hook(message, callback)¶
Register network message handler.
Parameters:
message(string): Message namecallback(function): Handler function
Returns:
- None
Example:
ax.config¶
ax.config:Set(key, value)¶
Set configuration value.
Parameters:
key(string): Configuration keyvalue(any): Configuration value
Returns:
- None
Example:
ax.config:Get(key, fallback)¶
Get configuration value.
Parameters:
key(string): Configuration keyfallback(any): Fallback value
Returns:
- (any): Configuration value
Example:
local serverName = ax.config:Get("server.name")
local maxPlayers = ax.config:Get("server.max_players", 32)
ax.util¶
ax.util:PrintSuccess(message)¶
Print success message (green).
Parameters:
message(string): Message
Returns:
- None
ax.util:PrintWarning(message)¶
Print warning message (yellow).
Parameters:
message(string): Message
Returns:
- None
ax.util:PrintError(message)¶
Print error message (red).
Parameters:
message(string): Message
Returns:
- None
ax.util:PrintDebug(message, color)¶
Print debug message (white).
Parameters:
message(string): Messagecolor(Color): Text color
Returns:
- None
ax.util:FindPlayer(target)¶
Find player by name or SteamID.
Parameters:
target(string): Search term
Returns:
- (Player|nil): Found player or nil
ax.util:FindPlayers(target)¶
Find all matching players.
Parameters:
target(string): Search term
Returns:
- (table): Table of matching players
ax.util:IsValidPlayer(entity)¶
Check if entity is valid player.
Parameters:
entity(Entity): Entity to check
Returns:
- (boolean): Entity is valid player
ax.util:IncludeDirectory(directory, recursive, exclude, timeFilter)¶
Include all files in directory.
Parameters:
directory(string): Directory pathrecursive(boolean): Include subdirectoriesexclude(table): Files/directories to excludetimeFilter(number): Only load files modified within timeFilter seconds
Returns:
- None
Example:
ax.util:IncludeDirectory("schema/factions", true)
ax.util:IncludeDirectory("schema/hooks", true, {
["cl_hooks.lua"] = true
})
ax.util:FindString(str, search)¶
Find string (case-insensitive partial match).
Parameters:
str(string): String to searchsearch(string): Search term
Returns:
- (boolean): String contains search term
ax.util:TokenizeString(str)¶
Tokenize string (respecting quotes).
Parameters:
str(string): String to tokenize
Returns:
- (table): Table of tokens
Example:
local tokens = ax.util:TokenizeString('say "hello world" arg2')
-- Returns: {"say", "hello world", "arg2"}
ax.util:UniqueIDToName(id)¶
Convert unique ID to display name.
Parameters:
id(string): Unique ID
Returns:
- (string): Display name
Example:
ax.database¶
Database Query Methods¶
mysql:Select(table)¶
Create SELECT query.
Parameters:
table(string): Table name
Returns:
- (table): Query object
mysql:Insert(table)¶
Create INSERT query.
Parameters:
table(string): Table name
Returns:
- (table): Query object
mysql:Update(table)¶
Create UPDATE query.
Parameters:
table(string): Table name
Returns:
- (table): Query object
mysql:Delete(table)¶
Create DELETE query.
Parameters:
table(string): Table name
Returns:
- (table): Query object
Query Methods¶
query:Where(column, value)¶
Add WHERE clause.
Parameters:
column(string): Column namevalue(any): Value
Returns:
- (table): Query object (for chaining)
query:Insert(column, value)¶
Add INSERT value.
Parameters:
column(string): Column namevalue(any): Value
Returns:
- (table): Query object (for chaining)
query:Update(column, value)¶
Add UPDATE value.
Parameters:
column(string): Column namevalue(any): Value
Returns:
- (table): Query object (for chaining)
query:Limit(count)¶
Add LIMIT clause.
Parameters:
count(number): Limit count
Returns:
- (table): Query object (for chaining)
query:Callback(callback)¶
Set callback function.
Parameters:
callback(function): Callback function
Returns:
- (table): Query object (for chaining)
Example:
local query = mysql:Select("ax_characters")
query:Where("faction", FACTION_CITIZEN)
query:Limit(10)
query:Callback(function(result, status)
if result then
for i = 1, #result do
print(result[i].name)
end
end
end)
query:Execute()
query:Execute()¶
Execute query.
Parameters:
- None
Returns:
- None
Continue to: Examples