Skip to content

Exports, hooks and events

Everything here is server side. Exports are server-to-server: a client cannot call them. exports.cc_scrapyard:getApi() lists every export and exports.cc_scrapyard:getHooks() every hook with its payloa

Everything here is server side. Exports are server-to-server: a client cannot call them. exports.cc_scrapyard:getApi() lists every export and exports.cc_scrapyard:getHooks() every hook with its payload, at runtime.

Exports

lua
local yard = exports.cc_scrapyard
ExportReturns
isWorking(src)booleanThe player has a strip job
getJob(src)table?{ id, kind, site, bay, tier, tierLabel, label, plate?, vin?, hotList, slots, carrying?, active?, jacked, hoist }
endJob(src, reason?)booleanEnds the job like /scrapyard quit (a wreck is removed, a chop car released)
getWorker(src)table?{ level, title, xp, xpFrom, xpTo, cars, chops, upgrades = { ids } }
addXp(src, amount)level?, levelledUp?Give (or take, negative) yard XP. ±100000 per call
hasYards()booleanAt least one yard enabled and the yard feature on
getHotList()string[], minutesModels on the chop hot list and minutes until it changes
rerollHotList()string[]Roll a new hot list now
getTier(model)integer?The tier the yard gives a model name or hash (nil = refused)
VinRecord(vin)table?{ vin, plate, model, tier, owned, ownerCitizenid?, area, at } — for an MDT
getVersion() / getApi() / getHooks()Standard on every Code Cartel resource
lua
-- an MDT looking up a seized part
local rec = exports.cc_scrapyard:VinRecord('SY0000042')
if rec then print(rec.plate, rec.model, rec.area, os.date('%c', rec.at)) end

Hooks

Register in custom/server.lua (escrow-ignored) or any server script that loads cc_lib:

lua
CC.hooks.register('<name>', function(payload) ... end)

A cancellable hook refuses by returning false. A mutable hook (filter) returns a new value; for prices it may only lower the value. Hooks can never grant or raise pay.

HookKindPayload
beforeJobStartcancellablesource, kind ('yard'|'own'|'chop'), tier, plate?, owned?
afterJobStartnotifysource, kind, tier, model, plate?, owned?, vin?, hotList?
afterPartStowednotifysource, kind ('yard'|'chop'), part, tier, vin?
payFiltermutablevalue = unit price or hull; context source, kind ('counter'|'fence'|'hull'), part?, tier
beforeSalecancellablesource, kind ('counter'|'fence'), part? (nil = sell all)
afterSalenotifysource, kind, units, paid, account
afterJobEndnotifysource, kind, how ('crushed'|'dumped'|'abandoned'|'idle'|'player left'|...), paid, tier
beforeDispatchcancellablesource, alert = { coords, title, description, code, jobs, priority, plate?, model, area, blip }, owned, tier — return false to send your own
isInsuredmutablevalue = what the insurance resource said (true/false/nil); context plate
upgradeBoughtnotifysource, upgrade, price

Seven worked examples are in custom/server.lua.

Client events (for cosmetics in custom/client.lua)

These are pushed by the server to one player. Listening is safe; triggering them yourself does nothing on the server.

EventArguments
cc_scrapyard:jobthe job snapshot, or nil when it ends
cc_scrapyard:carrypart key now in your hands, or nil
cc_scrapyard:strip:goslot index, milliseconds, skill-check keys
cc_scrapyard:fx:crushcrusher point, car coords, netId, operator source (everyone near)
cc_scrapyard:contractthe contract view, or nil

Server lifecycle event

cc_scrapyard:ready (server and client) fires once the API is published, with the version.

Commands

CommandWho
/scrapyard quiteveryoneWalk away from your job
/scrapyard helpeveryone
/vincheckpolice on duty (ServerConfig.Chop.policeJobs)VINs of the hot parts in your inventory
/scrapyard statusACE cc_scrapyard.adminVersion, framework, garage schema, ledger state
/scrapyard posadminPrint your position as a vec4
/scrapyard jobsadminEvery running job
/scrapyard end <id>adminEnd a player's job
/scrapyard xp <id> <amount>adminGive XP
/scrapyard hotlistadminReroll the hot list
/scrapyard restore <plate>adminPut back a car a player scrapped