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.
local inCrew = exports.cuxial_diving:IsInCrew(source)| Parameter | Type | Description |
|---|---|---|
source | number | Server id of the player. |
Returns: boolean.
if exports.cuxial_diving:IsInCrew(source) then
-- the player is busy with the diving job
endGetProfile
Returns the diving level and experience of a character. It works with the character offline too.
local profile = exports.cuxial_diving:GetProfile(citizenid)| Parameter | Type | Description |
|---|---|---|
citizenid | string | Character 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.
local profile = exports.cuxial_diving:GetProfile(citizenid)
if profile and profile.level >= 10 then
-- unlock something for experienced divers
endFinish 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.
function CuxialDiving.hooks.onFinish(src, data)
if data.region == 4 then
exports.my_resource:AddReputation(src, 5)
end
end| Parameter | Type | Description |
|---|---|---|
src | number | Server id of the player. |
data.runId | number | Id of the job in the history. 0 when it could not be saved. |
data.region | number | id of the region, from data/regions.lua. |
data.score | number | Required pieces collected by this player. |
data.money | number | Money paid to this player. |
data.xp | number | Experience given to this player. |
data.owner | string | Character 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 bag | Type | Description |
|---|---|---|
divingAnchor | boolean | true while the anchor is down. Read only: the server restores its own value if another resource changes it. |
fuel | number | Fuel level set when the boat spawns, from boat.fuel. |
local anchored = Entity(vehicle).state.divingAnchor == trueMoney reasons
Payments go through your framework with these reasons, which you can use to filter your own money logs.
| Reason | When |
|---|---|
cuxial-diving | Payout of a delivered job. |
cuxial-diving-daily | Reward of a daily task. |
cuxial-diving-market | Purchase or sale at the market. |
cuxial-diving-refund | Refund of a purchase that could not be delivered. |
