Skip to content

cc_business: exports, events and hooks (API reference)

Everything another resource can call. Server exports are exports.cc_business:(...). Arguments are checked inside each export, so a bad call returns false or nil. It never throws into your resource. Ex

Everything another resource can call. Server exports are exports.cc_business:(...). Arguments are checked inside each export, so a bad call returns false or nil. It never throws into your resource. Exports marked trusted answer only the resources listed in AccServerConfig.TrustedResources. (server/acc/sv_config.lua). Any other caller gets false, 'untrusted' or false, 'not_allowed'.

Ids: businessId is the business id (the same as its framework job name). citizenid is the framework character id (Qbox/QBCore citizenid, ESX identifier, ox_core charId). source is a server player id.

Society banking (server)

ExportArgumentsReturns
GetAccount(businessId)business id or job namenumber balance (0 when none)
AddMoney(businessId, amount, meta?)whole dollars > 0boolean
RemoveMoney(businessId, amount, meta?)whole dollars > 0; never below zeroboolean
GetSocietyBalance, AddSocietyMoney, RemoveSocietyMoneysame as abovesame
getAccountMoney, addAccountMoney, removeAccountMoneyqb-management style aliasessame
RecordCommissionPayment(businessId, amount, description, employeeCitizenid?)pays a commission from the society account (ledger type commission)boolean

The balance is cc_business_companies.bank_balance, written only by the suite's database layer (conditional UPDATEs). A frozen business (/businessfreeze) refuses debits.

Businesses, staff and duty (server)

ExportArgumentsReturns
GetBusiness(businessId)business row or nil
GetBusinessProgress(businessId){ enabled, level, label, xp, reputation, nextLevel, maxStaff, ... }
GetBusinessMaxStaff(businessId)number
HasBusinessPermission(source, businessId, permission)e.g. 'order_supplies', 'hire', 'payroll'boolean (read only)
IsBusinessAdmin(source)boolean (ACE cc_business.admin)
IsEmployeeOnDuty(citizenid, businessId?)no businessId = clocked in anywhereboolean
GetHoursThisWeek(businessId, citizenid)number seconds
OpenBusinessTablet(source)opens the tablet for that player-
RemoveCitizenQbxJob(...)removes a staff member's framework job (job businesses)boolean
SyncTabletDutyFromQbxJob, SetBusinessDutyFromPhone, PublishTabletDutyToLbPhone, IsStaffAvailableForBusinessCalllb-phone duty integration (see install/suite/INTEGRATIONS.md)

Memberships and doors (server)

ExportArgumentsReturns
HasMembership(citizenid, businessId, category?)boolean
GetBestMembership(citizenid, businessId)card table or nil
GetMembershipBenefits(citizenid, businessId)benefits table or nil
GetCheckoutDiscount(citizenid, businessId)discount for the POS
CanUnlockDoor(sourceOrCitizenid, doorKey, provider?), CanUnlockMembershipDoor(...)provider hint 'ox' or 'qb'boolean (for doorlock hooks)

Restricted (trusted callers only)

ExportTrusted listArgumentsReturns
AdminSetOwner(businessId, citizenid)admintrue / false, err
AdminSetStatus(businessId, status), AdminFire(businessId, citizenid)admintrue / false, err
ReceiveSupplyDelivery(businessId, items, ref)supply (cc_supply)items = { { item, count, metadata? }, ... }, ref = your unique delivery idtrue / true, 'already_received' / false, err. Idempotent per ref; goods go to the business's delivery stash; emits SupplyReady
BailFirmOf(src)bail (cc_doj){ id, label, cid } or nil, err
BailFirmDebit(businessId, amount, txType, ref, cid), BailFirmCredit(...)bailledgered firm moneyok, err
VacancyListOpen(source), VacancyDesk(source)jobcentre (cc_jobcentre)open postings / the player's hiring desk
VacancyPost(source, businessId, grade, wage, title)jobcentregrade = one of the business's own grades; wage bounded by Vacancies.minWage and StaffProfile.maxHourlyWageok, code
VacancyClose(source, id), VacancyApply(source, id), VacancyDecide(source, appId, accept)jobcentreok, code
ProvisionFromGmsRegistration(data)tcc_gms or shimsok, err
RecordJgSale, OnJgMechanicOrderPlaced / Fulfilled / CategoryInstalled, OnJgDealershipPurchase, GetMechanicOrderDetailthe jg resources or shimsjg's hook arguments
JimResolveBusinessId(job, gang)(read)business id or nil
GetBusinessBridgeStatus()(read)the website bridge's status

Every restricted export re-checks the player's permission itself. A trusted resource still cannot act for a player who lacks it.

Business events (server)

lua
local unsubscribe = exports.cc_business:SubscribeBusinessEvent('SaleCompleted', function(envelope)
    -- envelope = { event, at, businessId, actorSource, actorCitizenid, data, external, emitter }
end)
exports.cc_business:EmitBusinessEvent('MyEvent', { businessId = 'burgershot' })

Events raised by cc_business: SaleCompleted, RefundIssued, PayrollPaid, TaxPaid, ClockIn, ClockOut, RatingSubmitted, BusinessLevelUp, WeeklyReportReady, SupplyReady, SupplyCollected, SupplyCancelled. Handlers get a copy: changing it changes nothing.

Server hooks (veto / narrow)

Set AccServerConfig.Hooks.enabled = true first.

lua
local id = exports.cc_business:registerHook('beforeSale', function(payload)
    if payload.total > 50000 then return false, 'too large' end   -- cancel
    return { total = math.floor(payload.total * 0.9) }             -- narrow (only lower is applied)
end, { businessId = 'burgershot' })
exports.cc_business:removeHook(id)
HookCan
beforeSalecancel, or lower total
beforeRefund, beforeWithdrawcancel, or lower amount
beforePayroll, beforeHirecancel only
afterSale, afterPayrollobserve (after the money committed)

A hook that throws or runs past Hooks.budgetMs is ignored for that call (a broken plugin never blocks a sale) and removed after Hooks.maxStrikes. A raised value is ignored and logged.

Creator hooks (cc_lib CC.hooks)

CC.hooks.register(name, fn) in a server file of your own, or in custom/server.lua, which has working examples. Hooks only narrow: a raised price or a forged share is ignored.

beforePointUse, beforeShopPurchase, afterShopPurchase, afterShelfPurchase, beforeCraft, afterCraft, beforeRegisterCharge, beforeCommission, beforeDiscount, beforeGarageSpawn, beforeTeleport, afterOrderDelivered, beforeKioskSubmit, kioskReady, beforeBusinessSale, onBusinessSold, beforeMenuItemSave, beforeMenuRead, onMenuItemConsumed, beforeMysteryBox, afterMysteryBox, afterLayoutChange.

Custom point types

lua
exports.cc_business:registerPointType({
    key = 'arcade', label = 'Arcade machine', icon = 'gamepad',
    data = function(raw) return { game = tostring(raw.game or 'pong'):sub(1, 16) } end,   -- validator
    use = function(src, business, point, action) --[[ server side: the player used the point ]] end,
})

The validator is the only gate between the editor and your data: return only what you checked.

cc_lib API (CC.api)

getBusinesses(), getBusiness(id), getRole(src, id), getBackend().

Client exports

ExportReturns
OpenTablet(view?) / CloseTablet()opens / closes the tablet (view = 'pos', 'staff', ...)
GetDutyState()the last duty state the server pushed
IsInWorkZone(businessId)boolean, distance (display only: the server re-checks)
businesstabletox_inventory item export (export = 'cc_business.businesstablet')

Net events

You never trigger cc_business's net events yourself: every one is registered through CC.security.event with an argument schema, a cooldown and a lock, and it re-checks the player. Use the exports above.