Skip to content

Exports ​

All exports are server-side and called as exports.np_identification:<name>(...). They run the same code as the NUI paths (validation, logging, events), but skip the player permission checks: your resource decides who may call them.

server

Export Returns Description
getDocuments(src | citizenid) DocSummary[] The character's own records, without replaced ones. Accepts a server id or a citizen id (offline characters too)
hasValidDocument(src, typeKey) true, DocView | false The player has a valid (not expired, suspended, revoked or lost) document of this type
issueDocument(src, typeKey, inputs?, opts?) serial | nil, err Issue a document. See below
setStatus(serial, status, reason?, untilDays?) boolean 'valid', 'suspended', 'revoked', 'lost' or 'replaced'. untilDays (1–3650) sets the end of a suspension
addPoints(serial, points, reason, officer?) boolean Add 1–50 points. See below
registerWeapon(src, weaponSerial, label, caliber?) boolean Add a weapon to the player's valid weapon registry document
getType(key) TypeDef | nil A copy of the live definition of a document type
setWarrantProvider(fn) boolean Answer the warrant checks from your own resource. nil removes it. See Bridges → MDT

Each document item is also an export (exports.np_identification:id_card, …). They exist for ox_inventory's server.export hook (Installation → Items); don't call them yourself.

Used by np_vending ​

np_vending calls hasValidDocument for its age and licence locks:

  • 18+ slots (cigarettes, or any slot an owner locks by age) read the date of birth of a valid id_card. Without one, np_vending falls back to np_character's or the framework's date of birth.
  • Licence locks on slots, and models that need a licence to own (the cigarette machine needs a valid business_license), ask for that document type.

An expired, suspended, revoked or lost document counts as missing.

Used by np_metal-scanner ​

np_metal-scanner asks hasValidDocument for the permit classes of its checkpoints: firearm and blade permits are a valid weapon_license of category B or C (firearms) or A (blades), detecting a detecting_permit (the ground detector, when it requires one) and security a security_license. It reads getDocuments for the Permits phone app and calls addPoints when a seizure should cost a license point. The three types security_license, detecting_permit and implant_card ship as an import file (install/np_identification_typedefs.json): import them with /iddesigner and publish them (np_metal-scanner → Items).

Used by np_fishing ​

np_fishing checks the document type fishing_license (the Angelschein: city hall desk and the ranger job, a year, renewable online) with hasValidDocument(src, 'fishing_license'):

  • when the rod comes out, at every cast (the zone the float lands in) and when joining a tournament. Public piers are exempt. Config.License.required = 'auto' requires the licence only while np_identification runs.
  • Rangers see the licence state and its points when they check an angler.
  • Poaching (keeping a protected species or one in its closed season) adds licence points with addPoints.
  • np_fishing listens to np_identification:issued for its own document type.

On a version without the fishing_license type, create it in the designer with that key. An expired, suspended, revoked or lost document counts as missing.

issueDocument ​

lua
local serial, err = exports.np_identification:issueDocument(src, typeKey, inputs, opts)
Parameter Description
src Server id of the recipient. The character must be loaded
typeKey Document type key, for example 'id_card'
inputs { [fieldId] = value } for input.* fields and character fields the framework doesn't have (height on qb). Validated like desk input
opts.free true: no fee. Otherwise rules.price is charged
opts.account 'bank' (default) or 'cash'
opts.issuer { name, citizenid?, job? }, shown in issuer.* fields and stored with the record. Default: your resource name
opts.photo Photo as a data:image/jpeg;base64,… URL or an https:// URL from Config.ImageHosts
opts.signature SVG path data in a 0 0 400 120 view box
opts.validityDays Override the type's validity (1–3650)
opts.skipRequirements true: don't check rules.requires and maxActive

The flow is the same as at a desk: requirements, then payment, then the record, then the item (when physical cards are on). If the item doesn't fit, the record is deleted and the money refunded. On success np_identification:issued fires and the player gets a notification.

Error Meaning
not_ready The resource is still starting
no_player No loaded character for src
unknown_type No such type
requirements_not_met A requirement or maxActive failed
invalid_photo / invalid_signature The photo or signature was rejected
invalid_input / missing_input An input failed validation, or a required value is missing
not_enough_money Not enough money on the account
inventory_full The item didn't fit
busy Another issue for this character is in progress
lua
-- starter documents, paid by nobody
exports.np_identification:issueDocument(src, 'id_card', {}, { free = true })

-- a driving school script issues the licence after its own practical test
local serial, err = exports.np_identification:issueDocument(src, 'driver_license',
  { classes = { 'B' } },
  { issuer = { name = 'Driving School', job = 'drivingschool' }, account = 'cash' })
if not serial then
  TriggerClientEvent('my_school:failed', src, err)
end

addPoints ​

lua
exports.np_identification:addPoints(serial, points, reason, officer)

Only for types with rules.police.points. Each entry expires after Config.Points.expireDays. When the total reaches the type's rules.pointsMax, the document is suspended for Config.Points.suspendDays. The owner is notified when online. officer is a display name for the log.

lua
-- speed camera
local ok, doc = exports.np_identification:hasValidDocument(driver, 'driver_license')
if ok then exports.np_identification:addPoints(doc.serial, 1, ('%d km/h zu schnell'):format(over), 'Blitzer') end

registerWeapon ​

lua
exports.np_identification:registerWeapon(src, 'WPN-48213', 'Pistol', '9mm')

Adds the weapon to the player's valid weapon_license, or to another valid document whose type has rules.weaponSlots. It fails when there is no such document, the serial is already registered, or all slots are used. The registry shows on the Waffenregister back template.

Shapes ​

ts
DocSummary = {
  serial: string, type: string, label: string,
  state: 'valid' | 'expired' | 'suspended' | 'revoked' | 'lost' | 'replaced',
  expiresAt?: string,       // ISO date
  subtitle: string,         // holder name
}

DocView = {
  serial: string, type: string, version: number,
  values: Record<string, string | number | string[]>,   // field id -> value (dates ISO)
  photo?: string, signature?: string,
  state: 'valid' | 'expired' | 'suspended' | 'revoked' | 'lost' | 'replaced',
  statusReason?: string, statusUntil?: string,
  points?: number, pointsMax?: number,                  // only for types with points
  issuedAt: string, expiresAt?: string,
  meta?: { weapons?: { serial, label, caliber?, added }[] },
  holder?: { name: string },
}

TypeDef is described on Document types.