Skip to content

cc_jobcentre: exports, events and hooks (API reference)

Everything here is server-side. The client has no exports: the page and the client hold no authority, so there is nothing for another resource to call there.

Everything here is server-side. The client has no exports: the page and the client hold no authority, so there is nothing for another resource to call there.

Exports

lua
local jc = exports.cc_jobcentre

Reading the board (read-only, every value is a copy)

ExportReturnsNotes
jc:isReady()booleanThe board has been built from the config. Registrations are accepted before this too
jc:getJobs()table[]The active board in display order. Each entry has the Config.Jobs fields
jc:getJob(id)table?One active listing, or nil
jc:getStartupCost(id){ startup, reviewed }?From ServerConfig.Costs or the registration
jc:adviserReport()tableSpend today, caps, where answers came from (desk / cached / model / refused / failed)
jc:hasBoardOpen(src)booleanThe player has the board open right now
jc:getHooks(), jc:getApi(), jc:getVersion()cc_lib's standard discovery exports

There is no getEarnings: the office quotes no wages. A caller that wants to know what work pays asks the resource that pays it.

Listing your job from another resource

lua
-- in your job script, server side
local function list()
    exports.cc_jobcentre:registerJob({
        id        = 'mining',                 -- unique, lowercase
        label     = 'Quarry Miner',
        category  = 'handson',                -- one of Config.Categories (else Config.Registry.fallbackCategory)
        blurb     = 'Break rock at the quarry and sell what you dig.',
        where     = 'The quarry office, north of Sandy Shores.',
        coords    = vec3(2953.9, 2789.6, 41.5),
        applyVia  = 'walk_in',                -- walk_in | phone | hub | website | radio
        needs     = { { text = 'A pickaxe', item = 'pickaxe' }, 'A free afternoon' },
        steps     = { 'Talk to the foreman', 'Take a pickaxe from the rack', 'Mine the marked rocks' },
        tips      = { 'Ore sells for more at the smelter.' },
        aliases   = { 'mine', 'miner', 'quarry', 'ore' },
        image     = 'mining.webp',            -- optional, a file in cc_jobcentre/web/assets/jobs/
        startup   = 2500,                     -- what it costs to get started (display only)
        note      = 'The pickaxe is sold at the quarry.',
    })
end
AddEventHandler('cc_jobcentre:ready', list)                     -- cc_jobcentre (re)started after you
CreateThread(function() if GetResourceState('cc_jobcentre') == 'started' then list() end end)
ExportReturnsNotes
jc:registerJob(def)ok, reasonValidated with the same rules as Config.Jobs. The calling resource owns the listing; it goes when that resource stops. A config listing with the same id always wins
jc:unregisterJob(id)booleanRemoves a listing your resource registered

Start-up loans (only while ServerConfig.Loans.enabled)

These are for the job script named as the loan's provider. A call from any other resource returns false.

ExportReturnsWhen to call it
jc:drawStartupLoan(src, jobId, price)booleanIn your shop, when the player is short for the one start-up item. true = do not charge and hand the item over. price must be at most the loan's amount
jc:cancelStartupLoan(src, jobId)booleanYour purchase failed after a draw (no room, item refused). Puts the offer back
jc:reportLoanEarning(src, jobId, amount, account)booleanAfter every payout from your job, on frameworks without QBCore/Qbox's OnMoneyChange (ESX, ox_core, standalone). account is 'cash' or 'bank'. The loan's share is taken back from that account
lua
-- in your shop (server)
if not CC.money.canAfford(src, 'bank', price) then
    if exports.cc_jobcentre:drawStartupLoan(src, 'mining', price) then
        if not giveItem(src, 'mining_licence') then exports.cc_jobcentre:cancelStartupLoan(src, 'mining') end
        return
    end
    return notify(src, 'You cannot afford it.')
end

Events

All are local (server-to-server or client-to-client). None is a net event, so no client can trigger one.

EventSideArgumentsWhen
cc_jobcentre:readyserver + clientversionThe resource is up and takes registrations. Re-register on it
cc_jobcentre:server:answeredserversrc, kind, jobIdThe adviser answered (kind = desk / cached / model)
cc_jobcentre:server:boardChangedservercountThe board changed (config load, a registration, a provider stopped)
cc_jobcentre:openedclientlocationIdThe board opened on this client
cc_jobcentre:closedclientThe board closed

Hooks

Register in custom/server.lua (outside escrow, survives updates) with CC.hooks.register(name, fn); it ships with commented examples. Every handler runs in pcall, and whatever it returns is re-validated: a hook can narrow what the script does, never widen it.

HookKindPayloadWhat it can do
jobFiltermutablesource, job, visibleSet visible = false to hide a listing from one player (licence-gated trades, whitelists). It cannot add one
beforeAskcancellable, mutablesource, questionRewrite payload.question, or return false to drop it (the player gets the polite refusal)
afterAnswerinformationalsource, question, answer, kindLog, count, react
lua
-- custom/server.lua: only show the lawyer listing to players holding the bar licence
CC.hooks.register('jobFilter', function(p)
    if p.job == 'lawyer' and not CC.inventory.hasItem(p.source, 'bar_licence') then p.visible = false end
end)

Net events (for reference: what the client may send)

Every one goes through CC.security.event / CC.callback.register with an argument spec, a cooldown and an open-session check at the office. The client sends ids, never values.

NameArguments
cc_jobcentre:board (callback)locationId
cc_jobcentre:askquestion (string, length-capped)
cc_jobcentre:closed
cc_jobcentre:business (callback)
cc_jobcentre:biz:apply / :closevacancyId
cc_jobcentre:biz:postbusinessId, grade, wage, title (all checked by cc_business)
cc_jobcentre:biz:decideappId, accept
cc_jobcentre:loan:offerjobId
cc_jobcentre:selftestResulttwo counts (admin only, log only)