> 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/core/cuxial-multichar/developers.md).

# Exports & events

Public API of Cuxial Multichar: exports and events to review minor character requests from your own resources.

The public API covers minor character requests, so an admin panel or a staff tool can list, approve and manage them. All exports are server-side.

{% hint style="danger" %}
These exports do not check who is calling. Verify the staff permission in your own resource before calling `FamilyReview` or `FamilySetGrowth`.
{% endhint %}

{% hint style="info" %}
The exports need `family.enabled = true`. With minors disabled, `FamilyPending` returns `0` and the rest must not be called.
{% endhint %}

## The request object

`FamilyGet`, `FamilyList` and the `cuxial_multichar:family:Changed` event return requests with this shape:

| Field                      | Type         | Content                                                                                                      |
| -------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------ |
| `citizenid`                | string       | Citizenid of the minor                                                                                       |
| `status`                   | string       | `pending`, `approved`, `rejected` or `revoked`                                                               |
| `bond`                     | string       | `biological` or `adopted`                                                                                    |
| `father`, `mother`         | table / nil  | `{ citizenid, name, onlineId }`. `onlineId` is the server ID of the parent if that character is being played |
| `motivation`               | string       | Text written by the player                                                                                   |
| `child`                    | table        | `{ firstname, lastname, dob, age, gender, nationality }`. `gender` is `0` (male) or `1` (female)             |
| `playerName`               | string       | Name of the player who sent it                                                                               |
| `license`                  | string       | License of the player                                                                                        |
| `onlineId`                 | number / nil | Server ID of the player if connected                                                                         |
| `reviewedBy`, `reviewNote` | string / nil | Who reviewed it and the note                                                                                 |
| `reviewedAt`, `createdAt`  | number       | Timestamps in milliseconds. `reviewedAt` is `nil` until the request is reviewed                              |
| `growth`                   | table / nil  | `{ enabled, height, max, min, shrink, adult }`. Only for approved requests                                   |

## Exports

### FamilyPending

Number of requests waiting for review.

```lua
---@return integer
local pending = exports.cuxial_multichar:FamilyPending()
```

### FamilyGet

One request by citizenid.

```lua
---@param citizenid string
---@return table? request
local request = exports.cuxial_multichar:FamilyGet('ABC12345')
```

### FamilyList

Paginated list of requests. It takes one table with these fields, all optional:

| Parameter  | Type   | Content                                                                    |
| ---------- | ------ | -------------------------------------------------------------------------- |
| `status`   | string | `pending` (default), `approved`, `rejected`, `revoked`, `history` or `all` |
| `search`   | string | Filters by citizenid, player name or character name                        |
| `page`     | number | Page, from `1`                                                             |
| `pageSize` | number | Rows per page. Default `25`, maximum `100`                                 |

Returns `{ rows, total, page, pages, counts }`. `counts` holds `pending`, `approved`, `rejected`, `revoked` and `online`.

```lua
local result = exports.cuxial_multichar:FamilyList({ status = 'pending', page = 1 })

for _, request in ipairs(result.rows) do
    print(request.citizenid, request.child.firstname, request.status)
end
```

### FamilyReview

Approves, rejects or revokes a request. It takes one table:

| Parameter   | Type   | Content                                                                |
| ----------- | ------ | ---------------------------------------------------------------------- |
| `citizenid` | string | Citizenid of the minor                                                 |
| `decision`  | string | `approve` or `reject` for pending requests. `revoke` for approved ones |
| `note`      | string | Optional note shown to the player. Up to 300 characters                |
| `reviewer`  | table  | `{ name }` of the staff member. Saved as `Staff` when missing          |

Returns `true`, or an error string: `'not_found'` (no request for that citizenid), `'bad_state'` (the decision does not fit the current status) or `'bad_decision'` (unknown decision).

```lua
local result = exports.cuxial_multichar:FamilyReview({
    citizenid = 'ABC12345',
    decision = 'approve',
    note = 'Welcome',
    reviewer = { name = GetPlayerName(source) },
})
```

Revoking a minor who is being played sends that player back to the selection.

### FamilySetGrowth

Sets the height rules of an approved minor. It takes one table. Every call saves the four rules: the ones you leave out are saved as `false`, and `max` as the current height.

| Parameter   | Type    | Content                                                                           |
| ----------- | ------- | --------------------------------------------------------------------------------- |
| `citizenid` | string  | Citizenid of the minor                                                            |
| `enabled`   | boolean | Lets the player change height with the growth command                             |
| `max`       | number  | Maximum height in cm. Not lower than the current height and not higher than `200` |
| `shrink`    | boolean | Lets the player go below the current height                                       |
| `adult`     | boolean | Removes the scaling: the character uses the adult size                            |

Returns `true`, or an error string: `'not_found'` (no request for that citizenid), `'bad_state'` (the request is not approved) or `'bad_range'` (`max` out of range).

```lua
exports.cuxial_multichar:FamilySetGrowth({
    citizenid = 'ABC12345',
    enabled = true,
    max = 165,
    shrink = false,
    adult = false,
})
```

## Events

### cuxial\_multichar:family:Changed

Server event. Fires when a request is created, reviewed, changed with `FamilySetGrowth` or deleted. It receives the request object, with `status` set to `'deleted'` when the character was deleted.

```lua
AddEventHandler('cuxial_multichar:family:Changed', function(request)
    -- request.status: 'pending', 'approved', 'rejected', 'revoked' or 'deleted'
    print(request.citizenid, request.status)
end)
```

## State bag

`cuxialScale` is set on the player while they play an approved minor. It holds the scale factor (height divided by the adult reference height). It is `nil` for everyone else, and for minors marked as `adult`. It is replicated, so clients can read it too.

```lua
local scale = Player(source).state.cuxialScale
```


---

# 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/core/cuxial-multichar/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.
