Open the panels from your own targets or items, and read, issue, revoke and restore documents and badges from an MDT or any other resource.
Client exports
openGetCard
Opens the document store. With an office id it shows the cards of that office, the same as its NPC; without it, every card with Charge money that is not restricted to a job.
exports.cuxial_license:openGetCard(opts)| Parameter | Type | Description |
|---|---|---|
opts.office | string | Id of an office. Optional. The office must be open and visible to the player's job. |
exports.cuxial_license:openGetCard({ office = 'cityhall' })openAdmin
Opens the /license panel. Players without admin.permission get a "no permission" notice.
exports.cuxial_license:openAdmin()openJobManager
Opens the issuing panel. Cards, issued documents and nearby players are only delivered to staff and to the jobs in jobs.authorized and jobs.revoke.
exports.cuxial_license:openJobManager(data)| Parameter | Type | Description |
|---|---|---|
data.heading | string | Title of the panel. |
data.subHeading | string | Text under the title. |
data.logo | string | Image shown next to the title. |
data.jobName | string | Job name shown in the panel. |
exports.cuxial_license:openJobManager({
heading = 'Police Department',
subHeading = 'Licensing desk',
logo = 'https://example.com/logo.png',
jobName = 'police',
})openIdCheck
Opens the ID check panel. Scanning only returns data to staff and to the jobs in jobs.authorized and jobs.idCheck.
exports.cuxial_license:openIdCheck()openFakeId
Opens the fake ID generator. It is the only way to open it. The server checks fakeId.enabled, fakeId.jobs, fakeId.requiredItem and the cooldown before the panel opens.
exports.cuxial_license:openFakeId(data)| Parameter | Type | Description |
|---|---|---|
data.heading | string | Title of the panel. Optional. |
data.subHeading | string | Text under the title. Optional. |
exports.ox_target:addBoxZone({
coords = vec3(0.0, 0.0, 0.0),
size = vec3(1.0, 1.0, 2.0),
options = {
{
label = 'Forge a document',
onSelect = function()
exports.cuxial_license:openFakeId({ heading = 'Forger' })
end,
},
},
})Item exports
The inventory items point to these exports. You do not call them yourself; you reference them in the item definition, as shown in Installation.
| Export | Items | Shows |
|---|---|---|
cuxial_license.useLicenseCard | id_card, badge items and any item name set in the designer | A document or badge issued by the script |
cuxial_license.useFakeId | fake_id | A card made with the fake ID generator |
cuxial_license.useJobBadge | job_badge | A badge built from the item's metadata |
cuxial_license.useWorkerId | worker_id | A worker ID built from the item's metadata |
Badge and worker ID items
job_badge and worker_id are drawn from their own metadata, with no record in the database. Give them from your own resource:
| Item | Metadata |
|---|---|
job_badge | firstname (full name), rank, callsign, division or job, heading and footer (ribbon texts), shape, metal, insignia, logo, playerPhoto, issueDate, expireDate, isRevoked, colors |
worker_id | name, sex, job, rank, division, citizenId, issueDate, logo, playerPhoto, isRevoked, colors |
shape, metal and insignia take the badge values listed in Configuration. colors has body, bodyText, footer and footerText in hex.
exports.ox_inventory:AddItem(source, 'job_badge', 1, {
firstname = 'John Doe',
rank = 'Sergeant',
callsign = '214',
division = 'Patrol',
heading = 'POLICE DEPARTMENT',
shape = 'shield',
metal = 'silver',
insignia = 'star1',
})Server exports
GetPlayerLicenses
Returns the documents of a character that are not revoked. Expired ones are included.
exports.cuxial_license:GetPlayerLicenses(citizenId)| Parameter | Type | Description |
|---|---|---|
citizenId | string | Character identifier. |
Returns: table[]. Each entry has id (document id), type (id of the card design), label (title of the card), issueDate, expireDate ('YYYY-MM-DD', empty when it has no expiry) and expired (boolean).
for _, doc in ipairs(exports.cuxial_license:GetPlayerLicenses(citizenId)) do
print(doc.label, doc.expired)
endGetAvailableCards
Returns every card design on the server.
exports.cuxial_license:GetAvailableCards()Returns: table[]. Each entry has type (id of the design), label, restrictJob, restrictJobNames, issuedForJobs (jobs that can issue it), itemName, layout ('landscape', 'portrait', 'square' or 'badge') and kind ('id', 'license' or 'badge').
IssueLicense
Issues a card to a character, online or offline. It does not check permissions: do it in your resource before calling.
exports.cuxial_license:IssueLicense(issuerSrc, cardId, citizenId, opts)| Parameter | Type | Description |
|---|---|---|
issuerSrc | number | nil | Server id of the player who issues. nil records the issuer as SYSTEM. |
cardId | string | Id of the card design, the type of GetAvailableCards. |
citizenId | string | Character who receives it. |
opts.expireDate | string | Expiry date as 'YYYY-MM-DD'. Omit for no expiry. |
opts.metadata.playerPhoto | string | https link used as the photo of the card. Optional. |
Returns: { success = true, id = documentId }, with offline = true when the character was offline: then only the record is saved, with no item. On failure, { success = false, reason = '…' } with invalid_args, card_not_found, invalid_item or inventory_full.
If the character already holds that card, the existing record is updated, its revocation lifted and its id returned.
local result = exports.cuxial_license:IssueLicense(source, cardId, citizenId, {
expireDate = '2027-01-01',
})
if result.success then print('Issued', result.id) endRevokeLicense / RestoreLicense
Revoke or restore a document by id, with no permission check.
exports.cuxial_license:RevokeLicense(licenseId)
exports.cuxial_license:RestoreLicense(licenseId)Returns: boolean. true when the state changed.
GetCardTemplate
Returns the design of a card with its fields empty, for a resource that wants to draw the card and fill it in itself.
exports.cuxial_license:GetCardTemplate(query)| Parameter | Type | Description |
|---|---|---|
query.id | string | Id of the card design. |
query.item | string | Alternative to id: the card that hands out this item. |
Returns: table | nil. id, display (what the card shows, with its design or factory preset) and fields: first_name, last_name, citizenid, birthdate, gender, nationality, job, rank, callsign, issue_date, expiry_date. nil when no card matches.
local template = exports.cuxial_license:GetCardTemplate({ item = 'id_card' })GetCardDesign
Returns the layered design of a card, or nil. Cards made with an older version are returned converted, without saving them.
exports.cuxial_license:GetCardDesign(cardId)GetOffices
Returns the enabled offices, with the same fields as data/offices.lua and cards (ids of the designs it sells) in place of items.
exports.cuxial_license:GetOffices()ReprintDocument
Gives the holder a new copy of an issued document, for example after losing the item. src must be staff and the holder must be online.
exports.cuxial_license:ReprintDocument(src, licenseId)Returns: { success = true }, or { success = false, reason = '…' } with not_allowed, invalid_args, not_found, already_revoked, offline, invalid_item, inventory_full or too_fast.
Documents and badges for an MDT
These exports return { success = true, data = … } or { success = false, reason = '…' }. src is the player acting from the MDT: their job must be listed in jobs.authorized (issue) or jobs.revoke (revoke and restore), without looking at the grade. Staff always pass. Each action is limited to 5 every 10 seconds per player.
reason | When |
|---|---|
invalid_args | src is not an online player, or an argument is missing or of the wrong type |
not_allowed | The job of src is not listed, cannot issue that card, or IssueDocument was asked for a badge |
too_fast | Rate limit reached |
card_not_found | The card does not exist; for a badge, no Badge design uses the faction's item |
invalid_item / inventory_full | The item does not exist, or the holder cannot carry it |
offline | The holder is not online |
not_found | The document does not exist or belongs to another character |
already_revoked / not_revoked | Revoking something revoked, or restoring something that is not |
reason_required | Revocation reason shorter than documents.reasonMin |
invalid_date | expireDate is not YYYY-MM-DD or is in the past |
wrong_job | The badge holder has no job of that faction |
unknown_faction | The faction is not in documents.badges and the holder's job matches none |
internal | Internal error, or two issues at the same time to the same holder |
Document
The data of most of these exports is a Document, or a list of them:
| Field | Description |
|---|---|
id, cardId, type | Document id, design id (type is the same as cardId) |
label, kind, itemName, layout | Title, 'id' / 'license' / 'badge', item and layout |
holderName, issuedBy | Holder's name and character id of the issuer, or SYSTEM |
issueDate, expireDate | 'YYYY-MM-DD'; expireDate empty = no expiry |
status, expired, revoked | 'valid', 'expired' or 'revoked' (revoked wins), and both as booleans |
photo | https link or empty |
job, rank, callsign, faction | Data printed on the document |
restoredBy, restoredAt | Empty if it was never restored |
revokedReason, revokedBy, revokedByName, revokedAt | Only when status = 'revoked' |
GetCitizenDocuments
exports.cuxial_license:GetCitizenDocuments(citizenId, opts)| Parameter | Type | Description |
|---|---|---|
citizenId | string | Character identifier. |
opts.includeRevoked | boolean | true by default. |
opts.kind | string | 'id', 'license' or 'badge'. Optional filter. |
Data: Document[], newest first. It takes no src: decide in your MDT who can read it.
GetIssuableCards
exports.cuxial_license:GetIssuableCards(src)Data: the cards the job of src can issue, badges excluded. Each one has type, cardId, label, kind, itemName, layout, restrictJob, restrictJobNames and issuedForJobs.
IssueDocument
exports.cuxial_license:IssueDocument(src, target, cardId, opts)| Parameter | Type | Description |
|---|---|---|
target | number | string | Server id or character id of the holder. Must be online. |
cardId | string | Card to issue. Not a badge. |
opts.expireDate | string | 'YYYY-MM-DD', today or later. Optional. |
opts.photo | string | https photo. Accepted if it starts with a prefix of documents.photoHosts or is already on one of the holder's documents; otherwise the holder's last studio photo is used. |
opts.custom | table | Values of the card's custom fields. |
opts.division | string | Division printed on the card. Optional. |
Data: { id, cardId, citizenId, kind, reissued, updated, photo }. Issuing a card the holder already had reuses the record (reissued = true) and lifts its revocation.
IssueBadge
exports.cuxial_license:IssueBadge(src, target, opts)| Parameter | Type | Description |
|---|---|---|
target | number | string | Server id or character id of the holder. Must be online. |
opts.faction | string | Faction of documents.badges. By default, the one whose jobs include the holder's job. |
opts.callsign | string | Badge number. By default, callsign in the holder's metadata. |
opts.rank | string | Rank printed. By default, the label of the holder's grade. |
opts.photo, opts.expireDate, opts.custom, opts.division | As in IssueDocument. |
Data: as in IssueDocument. If the holder already carries that badge unrevoked, no second item is given: rank, number and photo are updated and updated = true.
local res = exports.cuxial_license:IssueBadge(source, targetId, { callsign = '214' })
if not res.success then print(res.reason) endRevokeDocument / RestoreDocument
exports.cuxial_license:RevokeDocument(src, citizenId, licenseId, reason)
exports.cuxial_license:RestoreDocument(src, citizenId, licenseId)reason must have between documents.reasonMin and documents.reasonMax characters. Restoring a badge requires the holder to have a job of the faction. Data: the updated Document.
RefreshHolder
Rewrites job, rank and badge number on the holder's badges, in the database and in their items if they are online, and revokes the badges of factions they left (with documents.revokeOnJobLoss).
exports.cuxial_license:RefreshHolder(target)Data: { citizenId, updated, revoked }. The script calls it on its own when an online player changes job or grade. Call it yourself after changing a player's badge number, or after promoting or firing someone who is offline.
GetBadgeFor / GetBadgeFactions
Return the badge of a job, or of every faction, without the { success, data } wrapper.
local badge = exports.cuxial_license:GetBadgeFor('police')
local all = exports.cuxial_license:GetBadgeFactions()Returns: GetBadgeFor gives { faction, item, cardId, shape, metal, logo, preset, ribbon = { top, bottom } }, or nil if the job has no faction. GetBadgeFactions gives { [faction] = … } with the same shape. Values follow the live settings.
Events
cuxial_license:client:OpenPanel
Opens a panel on a player from the server.
TriggerClientEvent('cuxial_license:client:OpenPanel', source, panel, data)| Parameter | Type | Description |
|---|---|---|
panel | string | 'admin', 'purchase' (store), 'manager' (issuing), 'idcheck' or 'fakeid'. |
data | table | Same table as the matching client export. 'purchase' takes { office = id }; 'idcheck' takes { scanId = serverId } to scan that player on open. |
TriggerClientEvent('cuxial_license:client:OpenPanel', source, 'idcheck', { scanId = targetId })Opening a panel gives no extra rights. Every action inside is checked again on the server.
cuxial_license:server:DocumentShown
Server-side, local (AddEventHandler). Fires once for each player who sees a document being shown.
AddEventHandler('cuxial_license:server:DocumentShown', function(payload)
-- payload.viewer, payload.holder, payload.holderCitizenId,
-- payload.cardId, payload.licenseId, payload.kind, payload.status
end)kind is 'id', 'license' or 'badge'; status is 'valid', 'expired' or 'revoked'.
cuxial_license:server:DocumentChanged
Server-side, local. Fires when a document is issued, revoked, restored or refreshed through the MDT exports or by a job change.
AddEventHandler('cuxial_license:server:DocumentChanged', function(payload)
if payload.action == 'revoked' and payload.by == 'SYSTEM' then
print(payload.citizenId, payload.reason)
end
end)| Field | Description |
|---|---|
action | 'issued', 'revoked', 'restored' or 'refreshed' |
citizenId, licenseId, cardId, kind | Document affected |
by, byName | Character id and name of who acted, or SYSTEM |
reason | Only for 'revoked' |
src | Server id of the player, when it came from an export |
