> For the complete documentation index, see [llms.txt](https://docs.cuxial.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cuxial.com/scripts/jobs/cuxial-gardener/developers.md).

# 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)
```

| Parameter | Type   | Description              |
| --------- | ------ | ------------------------ |
| `source`  | number | Server 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)
```

| Parameter    | Type   | Description                                                                |
| ------------ | ------ | -------------------------------------------------------------------------- |
| `identifier` | string | Character 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.

{% code title="server/hooks.lua" %}

```lua
function CuxialGardener.hooks.onFinish(src, data)
    -- your code
end
```

{% endcode %}

| Parameter     | Type   | Description                                                        |
| ------------- | ------ | ------------------------------------------------------------------ |
| `src`         | number | Server id of the player who was paid.                              |
| `data.runId`  | number | Id of the job in `cuxial_jobs_runs`. `0` if it could not be saved. |
| `data.region` | number | Region `id` from `data/regions.lua`.                               |
| `data.score`  | number | Tasks done by this player (mowing, pruning, branches, flowers).    |
| `data.bonus`  | number | Bonus tasks done by this player (watering, loading branches).      |
| `data.money`  | number | Money paid to this player.                                         |
| `data.xp`     | number | XP given to this player.                                           |
| `data.owner`  | string | Character 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
```

{% hint style="info" %}
An error inside the hook is caught and printed to the server console. The payment is not affected.
{% endhint %}

## Database

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

| Table                     | Content                                                                                                      |
| ------------------------- | ------------------------------------------------------------------------------------------------------------ |
| `cuxial_jobs_players`     | One row per character: `level`, `xp`, daily progress.                                                        |
| `cuxial_jobs_runs`        | Finished jobs: `region`, `owner`, `crew_size`, `outcome` (`done`, `reset`, `abandoned`), start and end time. |
| `cuxial_jobs_run_members` | What each member did and earned in a job: `score`, `bonus`, `money`, `xp`.                                   |
| `cuxial_jobs_audit`       | Audit rows: job finished, job reset, staff actions.                                                          |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.cuxial.com/scripts/jobs/cuxial-gardener/developers.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
