Skip to content

Exports & events

Public API of Cuxial Gardener: server exports and the hook that runs when a job is paid.

Check whether a player is working as a gardener, read their level, and run your own code when a job is paid. Everything here is server side. Cuxial Gardener has no client exports and no public events.

Server exports ​

IsInCrew ​

Tells whether a player is in a gardener crew. A crew exists from the moment the player opens the job panel, so this does not mean a job is in progress.

lua
exports.cuxial_gardener:IsInCrew(source)
ParameterTypeDescription
sourcenumberServer id of the player.

Returns: boolean.

lua
if exports.cuxial_gardener:IsInCrew(source) then
    -- the player is at the gardener job
end

GetProfile ​

Returns the gardener level and XP of a character. Works with offline characters too.

lua
exports.cuxial_gardener:GetProfile(identifier)
ParameterTypeDescription
identifierstringCharacter identifier of your framework (the citizenid on QBox and QBCore).

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

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

Hook: onFinish ​

server/hooks.lua is an open file. Its onFinish function runs once for each connected crew member when a job is paid. Write your code inside it: add reputation, give an extra reward, send your own log.

server/hooks.lua
lua
function CuxialGardener.hooks.onFinish(src, data)
    -- your code
end
ParameterTypeDescription
srcnumberServer id of the player who was paid.
data.runIdnumberId of the job in cuxial_jobs_runs. 0 if it could not be saved.
data.regionnumberRegion id from data/regions.lua.
data.scorenumberTasks done by this player (mowing, pruning, branches, flowers).
data.bonusnumberBonus tasks done by this player (watering, loading branches).
data.moneynumberMoney paid to this player.
data.xpnumberXP given to this player.
data.ownerstringCharacter identifier of the crew owner.
lua
function CuxialGardener.hooks.onFinish(src, data)
    if data.region == 5 and data.score >= 20 then
        exports.ox_inventory:AddItem(src, 'water', 1)
    end
end

An error inside the hook is caught and printed to the server console. The payment is not affected.

Database ​

Read-only queries are safe on these tables. Rows of this job have job = 'gardener'.

TableContent
cuxial_jobs_playersOne row per character: level, xp, daily progress.
cuxial_jobs_runsFinished jobs: region, owner, crew_size, outcome (done, reset, abandoned), start and end time.
cuxial_jobs_run_membersWhat each member did and earned in a job: score, bonus, money, xp.
cuxial_jobs_auditAudit rows: job finished, job reset, staff actions.

© Cuxial