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
client
exports['core_business']:OpenRegistry()Opens the business registry UI for the local player.
Example
lua
exports['core_business']:OpenRegistry()client
exports['core_business']:IsRegistryOpen()Returns whether the business NUI is currently open.
Returns:
booleanExample
lua
if exports['core_business']:IsRegistryOpen() then
print('Business UI is open')
endServer Exports — Data Access
server
exports['core_business']:GetBusiness(id)Returns a business object by ID from the cache.
| Parameter | Type | Description |
|---|---|---|
id | number | Business ID |
Returns:
Business | nilExample
lua
local business = exports['core_business']:GetBusiness(1)
if business then
print('Business:', business.name, 'Balance:', business.balance)
endserver
exports['core_business']:GetProperty(id)Returns a property object by ID from the cache.
| Parameter | Type | Description |
|---|---|---|
id | number | Property ID |
Returns:
Property | nilExample
lua
local property = exports['core_business']:GetProperty(5)
if property then
print('Property:', property.name, 'Type:', property.type)
endserver
exports['core_business']:GetEmployee(id)Returns an employee object by ID from the cache.
| Parameter | Type | Description |
|---|---|---|
id | number | Employee ID |
Returns:
Employee | nilExample
lua
local employee = exports['core_business']:GetEmployee(12)
if employee then
print('Employee:', employee.name, 'Role:', employee.role)
endserver
exports['core_business']:GetPlayerBusinesses(identifier)Returns all businesses where the player is a shareholder.
| Parameter | Type | Description |
|---|---|---|
identifier | string | Player identifier (citizenid or ESX identifier) |
Returns:
tableExample
lua
local businesses = exports['core_business']:GetPlayerBusinesses(citizenid)
for _, business in ipairs(businesses) do
print('Owns:', business.name)
endServer Exports — Creation
server
exports['core_business']:CreateBusiness(name, ownerIdentifier, ownerPercent)Creates a new business. The specified player becomes the owner with the given share percentage.
| Parameter | Type | Description |
|---|---|---|
name | string | Business name |
ownerIdentifier | string | Player identifier |
ownerPercent | number | Owner share percentage (default 100) |
Returns:
Business | nilExample
lua
local business = exports['core_business']:CreateBusiness('Los Santos Logistics', citizenid, 100)server
exports['core_business']:CreateProperty(data)Creates a new property from a data table.
| Parameter | Type | Description |
|---|---|---|
data | table | Property data (name, type, access_points, price, etc.) |
Returns:
Property | nilExample
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.
server
exports['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).
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | World coordinates to search from |
item | string | Item name to count |
Returns:
numberExample
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
endserver
exports['core_business']:closestPropertyRemoveItem(coords, item, amount)Removes an item from the closest property's storage. Returns true if no property found.
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | World coordinates to search from |
item | string | Item name to remove |
amount | number | Amount to remove |
Returns:
booleanExample
lua
-- Remove fuel from a gas station property when a player fuels up
exports['core_business']:closestPropertyRemoveItem(pumpCoords, 'fuel', 50)server
exports['core_business']:closestPropertyAddItem(coords, item, amount)Adds an item to the closest property's storage. Returns true if no property found.
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | World coordinates to search from |
item | string | Item name to add |
amount | number | Amount to add |
Returns:
booleanExample
lua
-- Add returned clothing to the store inventory
exports['core_business']:closestPropertyAddItem(storeCoords, 'clothing_item', 1)server
exports['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.
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | World coordinates to search from |
money | number | Amount of income |
log | string | Transaction description (optional) |
Returns:
booleanExample
lua
-- Register a fuel sale at a gas station
exports['core_business']:closestPropertyRegisterSale(
pumpCoords, 500, 'Fuel sale: 50L'
)server
exports['core_business']:closestPropertyRegisterExpense(coords, money, log)Registers an expense (deduction) from the business that owns the closest property.
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | World coordinates to search from |
money | number | Expense amount (will be made negative) |
log | string | Transaction description (optional) |
Returns:
booleanExample
lua
-- Deduct supply cost from the business
exports['core_business']:closestPropertyRegisterExpense(
storeCoords, 200, 'Restocking supplies'
)server
exports['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.
| Parameter | Type | Description |
|---|---|---|
coords | vector3 | World coordinates to search from |
item | string | Item name |
mode | string | sell (property sells to player) or buy (property buys from player) |
Returns:
number | nilExample
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')
endIntegration 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'
)