Store

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#

MethodParametersReturnsDescription
GetIsFrameworkAdminsrcbooleanCheck if a player has admin permissions
GetPlayerIdentifiersrcstring or nilGet the player's unique framework ID (citizenid / identifier)
GetPlayerNamesrcfirstName, lastNameGet the player's character name
GetPlayerJobDatasrctableGet the player's job information
GetAccountBalancesrc, accountTypenumberGet player balance ('cash' or 'bank')
RemoveAccountBalancesrc, accountType, amountbooleanRemove money from player account
GetFrameworkJobs--tableGet 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()
MethodParametersReturnsDescription
AddAccountMoneyjobName, amount, reasonbooleanDeposit money into a job account
GetAccountMoneyjobNamenumberGet a job account balance
RemoveAccountMoneyjobName, amount, reasonbooleanWithdraw 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()
MethodParametersReturnsDescription
Items--tableGet all registered items
GetItemInfoitemNametableGet item details (label, weight, image)
GetImagePathitemNamestringGet the NUI image path for an item
CanCarryItemsrc, itemName, quantitybooleanCheck if player can carry the item
AddItemsrc, itemName, quantitybooleanAdd 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()
MethodParametersReturnsDescription
AddLocalEntityentity, options--Add interaction options to an entity
RemoveLocalEntityentity, 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)
ParameterTypeDescription
urlstringDiscord webhook URL (empty string = disabled)
titlestringEmbed title
messagestringEmbed description
colorstring?Hex color for embed sidebar (defaults to accent color)
fieldstable?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:

  1. Open modules/framework/_default.lua in the legacy-lib resource
  2. Implement each function using your framework's API
  3. Each function has documentation explaining what it should return
  4. Restart your server

The same pattern applies to inventory (modules/inventory/_default.lua), target (modules/target/_default.lua), and banking (modules/banking/_default.lua).