Exports & hooks ​
What other resources may rely on. np_fishing depends on none of them (only oxmysql).
All exports are server-side unless marked client, called as exports.np_fishing:<name>(...). They answer nil,
false, 0 or {} until np_fishing is ready (np_fishing:server:ready), and every table they return is a plain
copy. Weights are grams, lengths centimetres.
The core exports keep answering when a gameplay module is removed (GetPlayerFishingLevel is 1 without the
progression module, IsFishing false without the loop); the order and price exports belong to the market module and
exist only with it.
Server ​
server
| Export | Returns | Description |
|---|---|---|
GetSpecies(id) |
{ id, label, rarity, water, weight = { min, max }, length, pricePerKg, item } | nil |
One species |
GetSpeciesList() |
list of the above | Sorted by rarity, then id |
GetZoneAt(coords) |
{ id, label, kind, water, boat } | nil |
A named water body, else coast or deep sea; nil for inland water (pools) |
GetBiteRating(coords | zoneId) |
Rating | nil | { score 0..100, label, period, zone, weather, season, hour, pressure } |
GetPlayerFishingLevel(src | identifier) |
number | The angler's level |
GetCatches(src | identifier, { species?, limit? }) |
Catch[] | Newest first |
GetRecord(species) |
Catch | nil | The heaviest one ever landed |
IsFishing(src) |
boolean | A line is in the water |
HasLicense(src) |
boolean | True when no licence is required |
registerHook(name, fn) |
id | nil | See Hooks; removed when your resource stops |
removeHook(id) |
boolean | |
GetFishPrice(species, weightG, quality?, buyer?) |
number | $ for one fresh fish; with a buyer id its demand and factors, else the base price |
GetFishOrders(filter?) |
Order[] | Open orders, newest first; filter = { status?, species?, kind?, issuer?, buyer?, limit? } |
CreateFishOrder(data) |
Order | nil, code | See Orders |
CancelFishOrder(id) |
boolean | Closes an open order (escrow left over goes back to its issuer) |
useItem is also an export: it is the item callback np_inventory and ox_inventory call
(server = { export = 'np_fishing.useItem' }). Don't call it yourself.
local rating = exports.np_fishing:GetBiteRating(GetEntityCoords(GetPlayerPed(src)))
if rating and rating.label == 'excellent' then ... end
A Catch is { id?, species, rarity, weight, length, quality 1..5, zone, cell, coords, identifier, name, caughtAt, bait?, lure?, legendary?, tournament?, status?, record? = { personal, server, first } }.
Client ​
client
| Export | Returns | Description |
|---|---|---|
IsFishing() |
boolean | The local player has a line in the water |
GetCurrentZone() |
{ id, label, kind, water } | nil |
Display only; the server decides with its own position |
GetFishingLevel() |
number | What the server last told this client |
Client events other resources may trigger:
| Event | Effect |
|---|---|
TriggerEvent('np_fishing:client:cancel', reason) |
Stops fishing (a cutscene, a call that must win) |
TriggerEvent('np_fishing:client:openMarket', buyerId) |
Opens a buyer's sell screen (the server still checks the distance) |
TriggerEvent('np_fishing:client:openTackleShop', shopId) |
Opens a bait & tackle counter (the server still checks the distance) |
Hooks ​
exports.np_fishing:registerHook(name, fn). Hooks run synchronously in registration order; an error is logged and
skipped.
| Hook | Payload | Return |
|---|---|---|
beforeCast |
{ source, identifier, zone, coords } |
false, reason refuses the cast |
beforeCatch |
{ source, identifier, catch } |
false, reason lets the fish escape |
beforeKeep |
{ source, identifier, catch } |
false, reason refuses the cooler (the player releases it) |
beforeSell |
{ source, identifier, buyer, items, total } |
false, reason refuses the sale |
beforeTournamentJoin |
{ source, identifier, tournament } |
false, reason refuses the entry (before the fee is taken) |
sellPrice |
{ source, identifier, buyer, species, weight, quality, freshness }, price |
A number replaces the price |
xpGain |
{ source, identifier, reason, catch? }, amount |
A number replaces the amount; reasons catch, release, achievement, collection, sell, admin |
sellPrice sees every fish the market prices (the sell screen, GetFishPrice), beforeSell every sale.
exports.np_fishing:registerHook('beforeSell', function(p)
if p.buyer == 'pearls' and not IsPierOpen() then return false, 'The pier is closed' end
end)
Orders ​
An Order is { id, kind = 'npc' | 'restaurant' | 'player', label, species, speciesLabel, rarity, minQuality, count, delivered, reward, perFish, status = 'open' | 'taken' | 'done' | 'expired', issuerName, buyer?, coords?, expiresAt, createdAt }.
CreateFishOrder(data) posts an order no player pays for: { species, count, reward, hours, minQuality?, label?, coords?, issuer?, issuerName?, kind?, deliverTo? }. deliverTo is the character identifier that gets the fish;
without it they are used up. A restaurant script:
local order = exports.np_fishing:CreateFishOrder({ species = 'mackerel', count = 5, minQuality = 3, reward = 600, hours = 2,
issuer = 'business:pearls', issuerName = "Pearl's Seafood", deliverTo = chefIdentifier,
coords = vector3(-1816.6, -1193.2, 14.3) })
Stats and items other resources may read ​
- Items: see Items. Fish metadata:
weight(g),length(cm),quality1..5,caught_at,spot,angler,catch,created/expires/shelf. - Angler stats (
np_fishing_players.stats):caught,kept,released,casts,grams,maxWeight,legendary,night,repairs,serverRecords,economy.sold,economy.earned,economy.spent,poaching. - Licences: the np_identification document type
fishing_license, see Licences & rangers.