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)
| Export | Arguments | Returns |
|---|---|---|
GetAccount(businessId) | business id or job name | number balance (0 when none) |
AddMoney(businessId, amount, meta?) | whole dollars > 0 | boolean |
RemoveMoney(businessId, amount, meta?) | whole dollars > 0; never below zero | boolean |
GetSocietyBalance, AddSocietyMoney, RemoveSocietyMoney | same as above | same |
getAccountMoney, addAccountMoney, removeAccountMoney | qb-management style aliases | same |
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)
| Export | Arguments | Returns |
|---|---|---|
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 anywhere | boolean |
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, IsStaffAvailableForBusinessCall | lb-phone duty integration (see install/suite/INTEGRATIONS.md) |
Memberships and doors (server)
| Export | Arguments | Returns |
|---|---|---|
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)
| Export | Trusted list | Arguments | Returns |
|---|---|---|---|
AdminSetOwner(businessId, citizenid) | admin | true / false, err | |
AdminSetStatus(businessId, status), AdminFire(businessId, citizenid) | admin | true / false, err | |
ReceiveSupplyDelivery(businessId, items, ref) | supply (cc_supply) | items = { { item, count, metadata? }, ... }, ref = your unique delivery id | true / 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(...) | bail | ledgered firm money | ok, err |
VacancyListOpen(source), VacancyDesk(source) | jobcentre (cc_jobcentre) | open postings / the player's hiring desk | |
VacancyPost(source, businessId, grade, wage, title) | jobcentre | grade = one of the business's own grades; wage bounded by Vacancies.minWage and StaffProfile.maxHourlyWage | ok, code |
VacancyClose(source, id), VacancyApply(source, id), VacancyDecide(source, appId, accept) | jobcentre | ok, code | |
ProvisionFromGmsRegistration(data) | tcc_gms or shims | ok, err | |
RecordJgSale, OnJgMechanicOrderPlaced / Fulfilled / CategoryInstalled, OnJgDealershipPurchase, GetMechanicOrderDetail | the jg resources or shims | jg'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)
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.
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)| Hook | Can |
|---|---|
beforeSale | cancel, or lower total |
beforeRefund, beforeWithdraw | cancel, or lower amount |
beforePayroll, beforeHire | cancel only |
afterSale, afterPayroll | observe (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
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
| Export | Returns |
|---|---|
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) |
businesstablet | ox_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.