Skip to content

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.

These exports do not check who is calling. Verify the staff permission in your own resource before calling FamilyReview or FamilySetGrowth.

The exports need family.enabled = true. With minors disabled, FamilyPending returns 0 and the rest must not be called.

The request object ​

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

FieldTypeContent
citizenidstringCitizenid of the minor
statusstringpending, approved, rejected or revoked
bondstringbiological or adopted
father, mothertable / nil{ citizenid, name, onlineId }. onlineId is the server ID of the parent if that character is being played
motivationstringText written by the player
childtable{ firstname, lastname, dob, age, gender, nationality }. gender is 0 (male) or 1 (female)
playerNamestringName of the player who sent it
licensestringLicense of the player
onlineIdnumber / nilServer ID of the player if connected
reviewedBy, reviewNotestring / nilWho reviewed it and the note
reviewedAt, createdAtnumberTimestamps in milliseconds. reviewedAt is nil until the request is reviewed
growthtable / 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:

ParameterTypeContent
statusstringpending (default), approved, rejected, revoked, history or all
searchstringFilters by citizenid, player name or character name
pagenumberPage, from 1
pageSizenumberRows 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:

ParameterTypeContent
citizenidstringCitizenid of the minor
decisionstringapprove or reject for pending requests. revoke for approved ones
notestringOptional note shown to the player. Up to 300 characters
reviewertable{ 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.

ParameterTypeContent
citizenidstringCitizenid of the minor
enabledbooleanLets the player change height with the growth command
maxnumberMaximum height in cm. Not lower than the current height and not higher than 200
shrinkbooleanLets the player go below the current height
adultbooleanRemoves 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👪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

© Cuxial