Skip to content

Exports & API

Core Business exposes exports for data access, business management, and a powerful closest-property API that lets any external script turn a property into a functional node (clothing store, ATM, fuel station, etc.).

Client Exports

clientexports['core_business']:OpenRegistry()

Opens the business registry UI for the local player.

Example
lua
exports['core_business']:OpenRegistry()
clientexports['core_business']:IsRegistryOpen()

Returns whether the business NUI is currently open.

Returns: boolean
Example
lua
if exports['core_business']:IsRegistryOpen() then
    print('Business UI is open')
end

Server Exports — Data Access

serverexports['core_business']:GetBusiness(id)

Returns a business object by ID from the cache.

ParameterTypeDescription
idnumberBusiness ID
Returns: Business | nil
Example
lua
local business = exports['core_business']:GetBusiness(1)
if business then
    print('Business:', business.name, 'Balance:', business.balance)
end
serverexports['core_business']:GetProperty(id)

Returns a property object by ID from the cache.

ParameterTypeDescription
idnumberProperty ID
Returns: Property | nil
Example
lua
local property = exports['core_business']:GetProperty(5)
if property then
    print('Property:', property.name, 'Type:', property.type)
end
serverexports['core_business']:GetEmployee(id)

Returns an employee object by ID from the cache.

ParameterTypeDescription
idnumberEmployee ID
Returns: Employee | nil
Example
lua
local employee = exports['core_business']:GetEmployee(12)
if employee then
    print('Employee:', employee.name, 'Role:', employee.role)
end
serverexports['core_business']:GetPlayerBusinesses(identifier)

Returns all businesses where the player is a shareholder.

ParameterTypeDescription
identifierstringPlayer identifier (citizenid or ESX identifier)
Returns: table
Example
lua
local businesses = exports['core_business']:GetPlayerBusinesses(citizenid)
for _, business in ipairs(businesses) do
    print('Owns:', business.name)
end

Server Exports — Creation

serverexports['core_business']:CreateBusiness(name, ownerIdentifier, ownerPercent)

Creates a new business. The specified player becomes the owner with the given share percentage.

ParameterTypeDescription
namestringBusiness name
ownerIdentifierstringPlayer identifier
ownerPercentnumberOwner share percentage (default 100)
Returns: Business | nil
Example
lua
local business = exports['core_business']:CreateBusiness('Los Santos Logistics', citizenid, 100)
serverexports['core_business']:CreateProperty(data)

Creates a new property from a data table.

ParameterTypeDescription
datatableProperty data (name, type, access_points, price, etc.)
Returns: Property | nil
Example
lua
local property = exports['core_business']:CreateProperty({
    name = 'Downtown Mine',
    type = 'mining_facility',
    price = 500000,
    access_points = { entrance = vector3(100, 200, 30) }
})

Server Exports — Closest Property API

These exports are the integration layer for external scripts. They find the closest property to a given coordinate and perform operations on it. This is how you turn any property into a node for another system (clothing, fuel, banking, etc.).

How It Works

Each export finds the closest property within 50 meters of the given coordinates by checking all access points. If no property is found, the exports return safe defaults (items return 1000.0, mutations return true) so external scripts don't break.

serverexports['core_business']:closestPropertyItemCount(coords, item)

Returns the total count of an item across all storages of the closest property. Returns 1000.0 if no property found (safe fallback so checks always pass).

ParameterTypeDescription
coordsvector3World coordinates to search from
itemstringItem name to count
Returns: number
Example
lua
-- Check if a clothing store property has enough stock
local count = exports['core_business']:closestPropertyItemCount(
    GetEntityCoords(GetPlayerPed(source)), 'clothing_item'
)
if count > 0 then
    -- Allow the sale
end
serverexports['core_business']:closestPropertyRemoveItem(coords, item, amount)

Removes an item from the closest property's storage. Returns true if no property found.

ParameterTypeDescription
coordsvector3World coordinates to search from
itemstringItem name to remove
amountnumberAmount to remove
Returns: boolean
Example
lua
-- Remove fuel from a gas station property when a player fuels up
exports['core_business']:closestPropertyRemoveItem(pumpCoords, 'fuel', 50)
serverexports['core_business']:closestPropertyAddItem(coords, item, amount)

Adds an item to the closest property's storage. Returns true if no property found.

ParameterTypeDescription
coordsvector3World coordinates to search from
itemstringItem name to add
amountnumberAmount to add
Returns: boolean
Example
lua
-- Add returned clothing to the store inventory
exports['core_business']:closestPropertyAddItem(storeCoords, 'clothing_item', 1)
serverexports['core_business']:closestPropertyRegisterSale(coords, money, log)

Registers income to the business that owns the closest property. The money is added to the business balance, recorded as a financial transaction, and tracked in statistics.

ParameterTypeDescription
coordsvector3World coordinates to search from
moneynumberAmount of income
logstringTransaction description (optional)
Returns: boolean
Example
lua
-- Register a fuel sale at a gas station
exports['core_business']:closestPropertyRegisterSale(
    pumpCoords, 500, 'Fuel sale: 50L'
)
serverexports['core_business']:closestPropertyRegisterExpense(coords, money, log)

Registers an expense (deduction) from the business that owns the closest property.

ParameterTypeDescription
coordsvector3World coordinates to search from
moneynumberExpense amount (will be made negative)
logstringTransaction description (optional)
Returns: boolean
Example
lua
-- Deduct supply cost from the business
exports['core_business']:closestPropertyRegisterExpense(
    storeCoords, 200, 'Restocking supplies'
)
serverexports['core_business']:closestPropertyGetPrice(coords, item, mode)

Returns the market listing price for an item at the closest property. Falls back to default_market prices for unowned properties.

ParameterTypeDescription
coordsvector3World coordinates to search from
itemstringItem name
modestringsell (property sells to player) or buy (property buys from player)
Returns: number | nil
Example
lua
-- Get the price of fuel at the nearest gas station
local price = exports['core_business']:closestPropertyGetPrice(
    pumpCoords, 'fuel', 'sell'
)
if price then
    print('Fuel costs $' .. price .. ' per unit')
end

Integration Examples

Gas Station (qb-fuel / ox_fuel / LegacyFuel)

Turn gas station properties into functional fuel nodes:

lua
-- In your fuel script's server-side sell handler:
local coords = GetEntityCoords(GetPlayerPed(source))

-- Check if the station has fuel in stock
local stock = exports['core_business']:closestPropertyItemCount(coords, 'fuel')
if stock < amount then
    -- Not enough fuel at this station
    return
end

-- Remove fuel from property storage
exports['core_business']:closestPropertyRemoveItem(coords, 'fuel', amount)

-- Get the price set by the property owner
local price = exports['core_business']:closestPropertyGetPrice(coords, 'fuel', 'sell')
local total = price * amount

-- Register the sale income to the business
exports['core_business']:closestPropertyRegisterSale(coords, total, 'Fuel sale: ' .. amount .. 'L')

Clothing Store (illenium-appearance / qb-clothing)

lua
-- When a player buys an outfit at a store location:
local coords = GetEntityCoords(GetPlayerPed(source))
local price = exports['core_business']:closestPropertyGetPrice(coords, 'clothing_item', 'sell')

-- Register the sale to the property's business
exports['core_business']:closestPropertyRegisterSale(
    coords, price or 500, 'Clothing purchase'
)

ATM (qb-banking / esx_banking)

lua
-- Register ATM transaction fees as income for the property owner
local coords = GetEntityCoords(GetPlayerPed(source))
local fee = math.floor(withdrawAmount * 0.02) -- 2% ATM fee

exports['core_business']:closestPropertyRegisterSale(
    coords, fee, 'ATM fee on $' .. withdrawAmount .. ' withdrawal'
)