Skip to content

cc_fishing — exports, events and hooks

Everything another resource can use. Nothing here can create money or fish from nothing: exports read state or do a bounded, logged action; hooks can only narrow what the script was already going to d

Everything another resource can use. Nothing here can create money or fish from nothing: exports read state or do a bounded, logged action; hooks can only narrow what the script was already going to do.

Server exports

lua
local fishing = exports.cc_fishing
ExportReturnsNotes
getLevel(src)integerAngler level (0 for an unknown / offline player)
getXp(src)integerTotal XP
getLicenceTier(src)0..40 = no licence
hasLicence(src)boolean
getCatch(src){ { item, kg, comp }, ... }comp = 'cooler' | 'pier'
isFishing(src)booleanA cast is out or the player is soaking
isSoaking(src)boolean2.0.0
getRebates(src)integerRebate credits held. 2.0.0
getCoolerTier(src)integer1..#tiers, 0 offline. 2.0.0
hasCoolerOut(src)booleanThe character's cooler stands in the world. 2.0.0
getPricePerKg(item)numberThis period's $/kg for a species (0 for an unknown item)
addXp(src, amount, reason)boolean1..100000 XP; logged with your resource's name. Can level the player up
grantLicence(src, reason)ok, codeFree tier-1 licence + card (+ starter cooler). Codes: already, no_player, cannot_carry, failed, busy. For welcome kits / events
getVersion()string
getApi()tableEvery export with its signature
getHooks()tableEvery hook with its payload
registerHook(name, fn)handleSame as CC.hooks.register from another resource
removeHook(id)booleanRemove a hook you registered (yours are also removed when your resource stops)
useItem(event, item, inventory)—ox_inventory's server.export target for the rods and the cooler. Not for you to call

Wholesale buyers (supply chains)

Only resources listed in ServerConfig.Supply.buyers may call these (checked with GetInvokingResource). Use them to sell fish somewhere other than this script's market.

ExportReturnsNotes
supplyCatch(src)fish[], compThe fish the buyer may read: the player's placed cooler when it stands within Distances.supplyCooler, else their pier catch
supplyTake(src, ids)token | nilRemoves exactly those catch ids (all or nothing, max 500) before you pay
supplyRestore(src, token)booleanYour payment failed: put the fish back (once, within 10 minutes)
lua
local list = exports.cc_fishing:supplyCatch(src)
local ids = {}
for _, f in ipairs(list or {}) do ids[#ids + 1] = f.id end
local token = exports.cc_fishing:supplyTake(src, ids)
if token and not payPlayer(src, total) then exports.cc_fishing:supplyRestore(src, token) end

Client exports (2.0.0)

ExportReturnsNotes
isFishing()booleanA session is open or a line is out
isSoaking()boolean
openRig()—Opens Rig Setup with the same checks as using a rod
stopFishing()—Ends the session / stands up from Soak a Line. Call it when your script cuffs, sedates or teleports the player

Server events (listen with AddEventHandler)

EventArguments
cc_fishing:server:catchKeptsrc, item, grams, dest
cc_fishing:server:fishSoldsrc, count, kg, total
cc_fishing:server:licenceBoughtsrc, tier
cc_fishing:server:purchasedsrc, shopId, qty, pay, cost
cc_fishing:server:levelUpsrc, from, to
cc_fishing:server:securityFlagsrc, reason, detail

Client events

EventArguments
cc_fishing:client:castStarted—
cc_fishing:client:landeditem, label, kg
cc_fishing:client:keptdest
cc_fishing:client:lostreason

Hooks

Register in custom/server.lua with CC.hooks.register(name, fn), or from another resource with exports.cc_fishing:registerHook(name, fn). Handlers run in pcall.

HookKindPayload / argumentsRule
beforeCastcancellable{ source, mode, rig, tier }return false to refuse; the bait is not taken
afterCatchinformational{ source, item, grams, dest, mode, xp, rebates }
beforePurchasecancellable{ source, what, price / credits, quantity }return false to refuse
purchasePricefilter(price, { source, what })raise only — a lower value is ignored
beforeSellcancellable{ source, count, kg, total }return false to refuse; the fish stay
saleTotalfilter(total, { source, count })lower only — a higher value is ignored
afterSellinformational{ source, count, kg, total }
afterLevelUpinformational{ source, from, to, xp }

Net events (for reference only)

Every inbound event goes through CC.security.event with a typed argument spec, a cooldown, an in-flight lock and a liveness check, and takes indices or ids only: cast:start (five Config.Gear indices), cast:result (ticket, passed), cast:keep / cast:release (ticket), shop:buy (shop index, quantity, pay), shop:sell, office:register / replace / upgrade / cooler (account), market:sell (catch id), market:sellAll, market:move, cooler:place (position, heading — distance-checked), cooler:pickup, soak:start, soak:stop, admin:boost (ACE). Calling them from another resource is unsupported; use the exports above.