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
serverexports['core_business']:closestPropertyGetBusinessId(coords)

Returns the business ID that owns the closest property. Useful for passing into Core Pay or any other export that needs a business ID.

ParameterTypeDescription
coordsvector3World coordinates to search from
Returns: number | nil
Example
lua
-- Get the business ID of the nearest property
local coords = GetEntityCoords(GetPlayerPed(source))
local businessId = exports['core_business']:closestPropertyGetBusinessId(coords)
if businessId then
    -- Use with Core Pay, billing, or any business operation
    exports['core_business']:requestCorePay(source, businessId, 100, 'Service fee')
end

Server Exports — Core Pay

Core Pay is a built-in billing UI that prompts the player to authorize a payment with a signature. The player sees the business name, logo, amount, and a signature canvas — they sign and hit "Authorize" to confirm, or cancel to decline. The payment is deducted from the player's bank and credited to the target business balance.

Use this export to trigger Core Pay from any script — for example, custom shops, services, or integrations that need a visual payment flow tied to a business.

serverexports['core_business']:requestCorePay(source, businessId, amount, description, callback)

Opens the Core Pay billing UI for a player. The player sees the business logo, payment amount, and a signature canvas. On authorize, the amount is deducted from the player's bank and added to the business balance. On cancel or insufficient funds, the callback receives false.

ParameterTypeDescription
sourcenumberPlayer server ID
businessIdnumberTarget business ID to receive the payment
amountnumberPayment amount in dollars
descriptionstringPayment reason shown in the UI (default: Payment)
cbfunctionCallback — receives (success, message). Optional.
Returns: void (result via callback)
Example
lua
-- Charge a player $250 for a service at business ID 3
exports['core_business']:requestCorePay(source, 3, 250, 'Vehicle Detailing', function(success, message)
    if success then
        print('Payment authorized')
        -- Give the player the service
    else
        print('Payment failed:', message)
    end
end)

How Core Pay Works

  1. Your script calls requestCorePay with the player, business, and amount
  2. The player sees a billing panel with the business logo, amount, and a signature canvas
  3. The player signs and clicks Authorize — or clicks Cancel
  4. Core Business deducts from the player's bank, credits the business balance, and logs the transaction
  5. Your callback fires with (true, "Payment successful") or (false, reason)

Core Pay with Closest Property

Use closestPropertyGetBusinessId to charge the player at whichever business owns the nearest property:

lua
local coords = GetEntityCoords(GetPlayerPed(source))
local businessId = exports['core_business']:closestPropertyGetBusinessId(coords)

if businessId then
    exports['core_business']:requestCorePay(
        source, businessId, 150, 'Store Purchase',
        function(success, msg)
            if success then
                -- Give the player the goods/service
            end
        end
    )
end

For integration examples using these exports, see the Integrations page.