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
local yard = exports.cc_scrapyard| Export | Returns | |
|---|---|---|
isWorking(src) | boolean | The 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?) | boolean | Ends 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() | boolean | At least one yard enabled and the yard feature on |
getHotList() | string[], minutes | Models 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 |
-- 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)) endHooks
Register in custom/server.lua (escrow-ignored) or any server script that loads cc_lib:
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.
| Hook | Kind | Payload |
|---|---|---|
beforeJobStart | cancellable | source, kind ('yard'|'own'|'chop'), tier, plate?, owned? |
afterJobStart | notify | source, kind, tier, model, plate?, owned?, vin?, hotList? |
afterPartStowed | notify | source, kind ('yard'|'chop'), part, tier, vin? |
payFilter | mutable | value = unit price or hull; context source, kind ('counter'|'fence'|'hull'), part?, tier |
beforeSale | cancellable | source, kind ('counter'|'fence'), part? (nil = sell all) |
afterSale | notify | source, kind, units, paid, account |
afterJobEnd | notify | source, kind, how ('crushed'|'dumped'|'abandoned'|'idle'|'player left'|...), paid, tier |
beforeDispatch | cancellable | source, alert = { coords, title, description, code, jobs, priority, plate?, model, area, blip }, owned, tier — return false to send your own |
isInsured | mutable | value = what the insurance resource said (true/false/nil); context plate |
upgradeBought | notify | source, 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.
| Event | Arguments |
|---|---|
cc_scrapyard:job | the job snapshot, or nil when it ends |
cc_scrapyard:carry | part key now in your hands, or nil |
cc_scrapyard:strip:go | slot index, milliseconds, skill-check keys |
cc_scrapyard:fx:crush | crusher point, car coords, netId, operator source (everyone near) |
cc_scrapyard:contract | the contract view, or nil |
Server lifecycle event
cc_scrapyard:ready (server and client) fires once the API is published, with the version.
Commands
| Command | Who | |
|---|---|---|
/scrapyard quit | everyone | Walk away from your job |
/scrapyard help | everyone | |
/vincheck | police on duty (ServerConfig.Chop.policeJobs) | VINs of the hot parts in your inventory |
/scrapyard status | ACE cc_scrapyard.admin | Version, framework, garage schema, ledger state |
/scrapyard pos | admin | Print your position as a vec4 |
/scrapyard jobs | admin | Every running job |
/scrapyard end <id> | admin | End a player's job |
/scrapyard xp <id> <amount> | admin | Give XP |
/scrapyard hotlist | admin | Reroll the hot list |
/scrapyard restore <plate> | admin | Put back a car a player scrapped |