Skip to content

Exports & events

Public API of Cuxial Diving: exports, the finish hook and the anchor state of the boat.

Read a diver's level, check whether a player is in a crew and run your own code when a job is paid. Cuxial Diving exposes no public events.

Server exports ​

IsInCrew ​

Tells whether a player is in a diving crew. A player has a crew from the moment they open the job panel.

lua
local inCrew = exports.cuxial_diving:IsInCrew(source)
ParameterTypeDescription
sourcenumberServer id of the player.

Returns: boolean.

lua
if exports.cuxial_diving:IsInCrew(source) then
    -- the player is busy with the diving job
end

GetProfile ​

Returns the diving level and experience of a character. It works with the character offline too.

lua
local profile = exports.cuxial_diving:GetProfile(citizenid)
ParameterTypeDescription
citizenidstringCharacter identifier, as given by your framework.

Returns: { level: number, xp: number }, or nil when the character has no diving profile or the database is not ready.

lua
local profile = exports.cuxial_diving:GetProfile(citizenid)
if profile and profile.level >= 10 then
    -- unlock something for experienced divers
end

Finish hook ​

server/hooks.lua is open for editing. Its function CuxialDiving.hooks.onFinish runs on the server once for each connected member, right after they are paid for a delivered job.

server/hooks.lua
lua
function CuxialDiving.hooks.onFinish(src, data)
    if data.region == 4 then
        exports.my_resource:AddReputation(src, 5)
    end
end
ParameterTypeDescription
srcnumberServer id of the player.
data.runIdnumberId of the job in the history. 0 when it could not be saved.
data.regionnumberid of the region, from data/regions.lua.
data.scorenumberRequired pieces collected by this player.
data.moneynumberMoney paid to this player.
data.xpnumberExperience given to this player.
data.ownerstringCharacter identifier of the crew owner.

The hook does not run for jobs that are reset or cancelled, nor for members who are disconnected at delivery. An error inside it is printed to the console and does not stop the payout.

Boat state ​

The work boat carries two replicated state bags that other resources can read.

State bagTypeDescription
divingAnchorbooleantrue while the anchor is down. Read only: the server restores its own value if another resource changes it.
fuelnumberFuel level set when the boat spawns, from boat.fuel.
lua
local anchored = Entity(vehicle).state.divingAnchor == true

Money reasons ​

Payments go through your framework with these reasons, which you can use to filter your own money logs.

ReasonWhen
cuxial-divingPayout of a delivered job.
cuxial-diving-dailyReward of a daily task.
cuxial-diving-marketPurchase or sale at the market.
cuxial-diving-refundRefund of a purchase that could not be delivered.

© Cuxial