Developers
The scuba diving client and server exports, the functions left open for your own code, and the files that ship open, with signatures, return shapes and Lua examples.
Every export is called on exports.lation_diving. Server exports that act on a player take their server id as source; client exports work on the local player. A player's identifier is the ESX identifier on ESX and the citizenid on Qbox and QBCore.
Client exports
| Export | Returns |
|---|---|
openMenu() | Nothing |
isGearEquipped() | Whether the player is wearing scuba gear |
getPlayerData(type?) | The player's record, or one field of it |
getLevelData() | The XP for each level |
openMenu
Client export
exports.lation_diving:openMenu()Opens the clerk's Scuba Diving menu wherever the player is, after asking CanOpenMenu. It doesn't check setup.job or the clerk's hours, so check what you need before calling it. The shops, the boat deposit and the refund still only go through within 15 meters of start.coords, unless you set it to false.
-- With start.coords = false: open the menu from your own ped or zone
exports.lation_diving:openMenu()isGearEquipped
Client export
local wearing = exports.lation_diving:isGearEquipped()Returns
booleantruewhile the player has scuba gear on
if exports.lation_diving:isGearEquipped() then
return lib.notify({ description = 'Take your scuba gear off first', type = 'error' })
endgetPlayerData (client)
Client export
local data = exports.lation_diving:getPlayerData(type)Parameters
typestringoptionaldefaultnil- One field:
identifier,name,level,exp,crates,depthorswam. The whole record when left out.
Returns
table | any- The record (see the server export), or the value of
type
Asks the server, so it waits for the answer. The first time a player is looked up, their record is made at level 1.
local level = exports.lation_diving:getPlayerData('level')getLevelData
Shared export
local levels = exports.lation_diving:getLevelData()Returns
table- The total XP for each level, keyed by level:
experienceinconfig/shared.lua
The same export exists on the client and the server.
{ [1] = 0, [2] = 2500, [3] = 10000, [4] = 20000, [5] = 50000 }Server exports
| Export | Returns |
|---|---|
getPlayerData(source, type?) | A player's record, or one field of it |
addPlayerData(source, dataType, amount) | Nothing |
getLevelData() | The XP for each level |
getPlayerData
Server export
local data = exports.lation_diving:getPlayerData(source, type)Parameters
sourcenumber- The player's server id
typestringoptionaldefaultnil- One field:
identifier,name,level,exp,crates,depthorswam. The whole record when left out.
Returns
table | any | nil- The record (below), or the value of
type.nilwhen the player isn't loaded in your framework.
The first time a player is looked up, a record is made at level 1 and saved. The record is the cached one, so treat it as read-only and change it with addPlayerData.
{
identifier = 'ABC12345',
name = 'Jane Doe', -- character name when the record was made
level = 2,
exp = 3120, -- total XP
crates = 914, -- crates picked up
depth = 239, -- deepest dive, in feet unless setup.metric is on
swam = 21245, -- distance swum underwater in scuba gear, same unit
}local level = exports.lation_diving:getPlayerData(source, 'level')
if level and level >= 3 then
-- let them buy from your own dive gear shop
endaddPlayerData
Server export
exports.lation_diving:addPlayerData(source, dataType, amount)Parameters
sourcenumber- The player's server id
dataTypestringexp,crates,swamordepthamountnumber- How much to add. Anything 0 or below does nothing, except for
depth.
dataType | What happens |
|---|---|
exp | Adds XP and moves the player up past each level they reach, up to the top level. No notice is shown. |
crates, swam | Adds amount to the total. |
depth | Replaces the deepest dive with amount. |
Nothing is written straight away: the record is saved when the player leaves, when the resource stops and when txAdmin shuts the server down.
-- 250 diving XP for finishing your own beach clean-up job
exports.lation_diving:addPlayerData(source, 'exp', 250)Functions to edit
These ship empty or simple in the open files, for your own code.
CanOpenMenu
function
function CanOpenMenu()
return true
endReturns
booleanfalsekeeps the menu shut
Asked every time the menu opens, from the clerk or from openMenu.
-- Only on foot
function CanOpenMenu()
return not cache.vehicle
endCrateCollected
function
function CrateCollected(source, quantity)
endParameters
sourcenumber- The player who picked the crate up
quantitynumber- How many crate items they got
Called each time a player picks up a crate, after the crate is in their inventory and before their XP is added.
DivingStopped
function
function DivingStopped(source)
endParameters
sourcenumber- The group's leader
Called when a group's dive ends: the leader picks Stop Diving or Stop in Continue Diving?, or, with start.continue off, the leader picks up the last crate.
Open files
These ship open, outside the escrow, so you can edit them:
| File | What to change there |
|---|---|
bridge/client.lua, bridge/server.lua | Another framework or inventory: players, jobs, money, items, usable items and locking the inventory. Each function has an "Add custom … here" branch. |
client/functions.lua | Notifications, progress bars, menus, dialogs, text prompts and targets (each custom option), the keys and fuel scripts, the clothes swap, the clerk ped and CanOpenMenu. |
server/functions.lua | Where the hotspot messages go (SendEmail), logging, opening crates and refilling gear, plus CrateCollected and DivingStopped. |
When you add a custom input dialog, note that ShowInput in client/functions.lua tests shared.setup.dialogss for its custom branch; correct it to dialogs so yours runs.
The hotspot messages go through SendEmail(source, message) in server/functions.lua. To use another phone, add a branch for it:
elseif Phone == 'my-phone' then
exports['my-phone']:sendMail(source, 'Diving Expert', 'Scuba Diving', message) Add your phone to InitializePhone at the top of the same file too, so it's found on start.
Still stuck? Ask in our Discord: the people who write the scripts answer.
Last updated