Integration
API reference for Legacy Lib exports and modules
Legacy Lib provides exports that other resources can use to access framework functions, inventory management, targeting, banking, and utilities.
Framework Module#
Access framework-specific player data with a unified API.
local Framework = exports['legacy-lib']:Framework()
Methods#
| Method | Parameters | Returns | Description |
|---|---|---|---|
GetIsFrameworkAdmin | src | boolean | Check if a player has admin permissions |
GetPlayerIdentifier | src | string or nil | Get the player's unique framework ID (citizenid / identifier) |
GetPlayerName | src | firstName, lastName | Get the player's character name |
GetPlayerJobData | src | table | Get the player's job information |
GetAccountBalance | src, accountType | number | Get player balance ('cash' or 'bank') |
RemoveAccountBalance | src, accountType, amount | boolean | Remove money from player account |
GetFrameworkJobs | -- | table | Get all registered framework jobs |
Job Data Format#
GetPlayerJobData returns a table with:
{
jobName = "police", -- Job identifier
jobLabel = "Police", -- Display name
gradeName = "sergeant", -- Grade identifier
gradeLabel = "Sergeant", -- Grade display name
gradeRank = 3, -- Grade level number
boss = false, -- Is the player a boss
onDuty = true, -- Is the player on duty
}
Example#
local Framework = exports['legacy-lib']:Framework()
-- Server-side: Get player info
local identifier = Framework.GetPlayerIdentifier(source)
local firstName, lastName = Framework.GetPlayerName(source)
local balance = Framework.GetAccountBalance(source, 'bank')
Banking Module#
Manage job/society bank accounts.
local Banking = exports['legacy-lib']:Banking()
| Method | Parameters | Returns | Description |
|---|---|---|---|
AddAccountMoney | jobName, amount, reason | boolean | Deposit money into a job account |
GetAccountMoney | jobName | number | Get a job account balance |
RemoveAccountMoney | jobName, amount, reason | boolean | Withdraw from a job account |
Example#
local Banking = exports['legacy-lib']:Banking()
-- Deposit $500 into the police account
Banking.AddAccountMoney('police', 500, 'Fine payment')
Inventory Module#
Manage player inventories with a unified API.
local Inventory = exports['legacy-lib']:Inventory()
| Method | Parameters | Returns | Description |
|---|---|---|---|
Items | -- | table | Get all registered items |
GetItemInfo | itemName | table | Get item details (label, weight, image) |
GetImagePath | itemName | string | Get the NUI image path for an item |
CanCarryItem | src, itemName, quantity | boolean | Check if player can carry the item |
AddItem | src, itemName, quantity | boolean | Add an item to a player's inventory |
Example#
local Inventory = exports['legacy-lib']:Inventory()
-- Check and add items
if Inventory.CanCarryItem(source, 'bread', 5) then
Inventory.AddItem(source, 'bread', 5)
end
Target Module#
Add and remove target interactions on entities (client-side).
local Target = exports['legacy-lib']:Target()
| Method | Parameters | Returns | Description |
|---|---|---|---|
AddLocalEntity | entity, options | -- | Add interaction options to an entity |
RemoveLocalEntity | entity, optionNames? | -- | Remove interactions from an entity |
Options Format#
Target.AddLocalEntity(ped, {
{
name = 'unique_id',
label = 'Open Shop',
icon = 'fas fa-shopping-basket',
distance = 2.5,
onSelect = function()
-- Your code here
end,
},
})
Utility Exports#
GetAccentColor#
Get the global accent color configured in Legacy Lib.
-- Client or server
local color = exports['legacy-lib']:GetAccentColor()
-- Returns: '#4ADE80' (or whatever is configured)
GetLocale#
Load locale strings for a resource.
-- Server-side
local Locale = exports['legacy-lib']:GetLocale(GetCurrentResourceName())
-- Returns: table of key-value locale strings from locales/en.json
SendWebhook#
Send a Discord webhook with an embedded message.
-- Server-side
exports['legacy-lib']:SendWebhook(url, title, message, color, fields)
| Parameter | Type | Description |
|---|---|---|
url | string | Discord webhook URL (empty string = disabled) |
title | string | Embed title |
message | string | Embed description |
color | string? | Hex color for embed sidebar (defaults to accent color) |
fields | table? | Array of { name, value, inline } |
CheckVersion#
Check if a resource is up to date against the remote version list.
-- Server-side
exports['legacy-lib']:CheckVersion(GetCurrentResourceName(), Config.Version)
Adding Custom Framework Support#
Each module includes a _default.lua file with documented function stubs. To add support for a custom framework:
- Open
modules/framework/_default.luain thelegacy-libresource - Implement each function using your framework's API
- Each function has documentation explaining what it should return
- Restart your server
The same pattern applies to inventory (modules/inventory/_default.lua), target (modules/target/_default.lua), and banking (modules/banking/_default.lua).