Skip to content

Exports, hooks and events

Everything here is server-side. All of it is read-only or narrowing: no export, hook or event lets another resource give items or money through this script.

Everything here is server-side. All of it is read-only or narrowing: no export, hook or event lets another resource give items or money through this script.

Exports

lua
local dumpster = exports.cc_dumpster
ExportArgumentsReturnsNotes
getLevel(src)player server idintegerScavenger level. 1 when the player is unknown or offline
getStats(src)player server idtable | nil{ level, xp, searches, finds, rares, injuries, earned, best, perks }, the same snapshot the panel shows
isHidden(src)player server idbooleanIs the player hiding in a dumpster right now?
isSearching(src)player server idbooleanIs the player mid-search?
forceOut(src)player server idnothingPuts a hidden player out. Use it from your own police search or jail script
countPicked()noneintegerHow many dumpsters are picked (empty) right now
getVersion()nonestringResource version, published through cc_lib
getApi()nonetableDescription of the exports and hooks, published through cc_lib
registerHook(name, fn)hook name, functionhandleSee Hooks

The 1.0 names still work: GetScavengerLevel(src), IsHidden(src) and ForceOutOfDumpster(src).

lua
-- example: block searching for on-duty police
if exports.cc_dumpster:isSearching(src) then return end
local level = exports.cc_dumpster:getLevel(src)

State bag

Player(src).state.cc_dumpster_hidden is true while the player is hiding. Only the server writes it, so your MDT, HUD or anticheat can read it on either side.

Hooks

Register a hook from your own resource. Your handler runs inside pcall, so a bug in it can never break a search. Hooks narrow what the server was going to do and never widen it. The server re-caps every value after your hook runs: finds can be removed or reduced but not added, and prices and payouts can only go down.

lua
exports.cc_dumpster:registerHook('canSearch', function(p)
    if exports.my_jobs:isOnDuty(p.source) then
        return false            -- refuse this search
    end
end)

exports.cc_dumpster:registerHook('filterFinds', function(p)
    for i = #p.finds, 1, -1 do
        if p.finds[i].item == 'rolex' then table.remove(p.finds, i) end   -- remove
    end
end)
HookCan cancelCan changePayload
canSearchyessource, kind, coords, level
filterFindsfinds (remove or reduce only)source, kind, area, level, finds[{ item, count, tier }]
afterSearchsource, kind, area, level, xp, hazard, finds, dropped
canHideyessource, coords
beforeSellyesmultiplier (0 to 1)source, multiplier
afterSellsource, paid, sold[{ item, count, total }]
beforeBuyyesprice (down only)source, index, item, count, price
beforeWalletyescash (down only)source, cash
afterWalletsource, cash, bonus

Return false from a cancellable hook to refuse the action. The player sees a short "not right now" message.

Events (server, outbound)

Listen with AddEventHandler (not RegisterNetEvent: these never come from a client):

lua
AddEventHandler('cc_dumpster:server:searchCompleted', function(src, data) end)
Eventdata
cc_dumpster:server:searchCompletedkind, finds, dropped, hazard, level, xp, area, coords
cc_dumpster:server:junkSoldpaid, sold
cc_dumpster:server:itemBoughtitem, count, price
cc_dumpster:server:walletOpenedcash, bonus
cc_dumpster:server:hiddencoords
cc_dumpster:server:hiderFoundby, coords
cc_dumpster:readyversion (no src)

custom/server.lua

If you would rather not write a second resource, use custom/server.lua. It is not escrowed and loads last:

lua
function Custom.onSearch(src, result)
    -- result = { kind, finds, dropped, hazard, level, xp, area, coords }
end

Admin command

/dumpsteradmin needs the ACE cc_dumpster.admin:

CommandWhat it does
/dumpsteradminStatus: how many dumpsters are picked right now
/dumpsteradmin refillRefill every dumpster now
/dumpsteradmin xp <id> <amount>Add XP to a player
/dumpsteradmin setxp <id> <xp>Set a player's XP

Net events (for reference)

These are the only events a client can send. Each one goes through cc_lib's CC.security.event, which checks the argument types, a cooldown, one request in flight, and whether the player is alive, uncuffed and on foot. You never call them yourself.

EventArgumentsChecked
cc_dumpster:search:startpos, modelReach from the server's own player position, model is a configured dumpster or bin, cooldown, hourly, new-spot and density caps, shared claim
cc_dumpster:search:finishticket, carefulSingle-use ticket, server time floor, finish reach
cc_dumpster:search:cancelticketThe ticket must be the player's own
cc_dumpster:hide:enter / hide:exitpos / noneReach, one hider, the canHide hook
cc_dumpster:hide:checkposPolice job, reach
cc_dumpster:recycler:sellnoneDistance to the recycler, hourly cash cap
cc_dumpster:recycler:buyshop line indexIndex range, distance, canCarry before charging, refund on failure