Skip to content

Exports ​

What other resources may rely on. Every export here is checked against the code by np_prison's test suite.

  • Months are roleplay months; one lasts Config.MonthSeconds (30) seconds of online time.
  • who is a server id or a character identifier (ESX identifier, qb citizenid, standalone license).
  • Exports trust the calling resource: they skip the job checks of commands and net events.

Server exports ​

server

exports.np_prison:<Name>(...). They never throw; failures answer false, '<code>'. Codes: no_player, invalid_params, already_jailed, not_jailed, vetoed, not_found, busy.

Export Returns
JailPlayer(source, months, facility?, opts?) true, view or false, code (view = { jailed, status, facility, cell, security, monthsTotal, monthsServed, monthsLeft, behaviour, account, bookedAt, number, … }). facility = a facility id or a 1-based index (pickle_prisons style); nil picks by length. opts = { reason?, by?, security? }
UnjailPlayer(who, opts?) true or false, code. opts = { reason?, by?, status = 'released' | 'paroled' | 'escaped', expectedBookingId? }; when supplied, the release succeeds only if the inmate is still in that booking. Passing true means escaped (pickle_prisons' breakout flag)
IsJailed(who) boolean
GetSentence(who) Sentence or nil, including current bookingId
BookLawyerVisit(source, inmateIdentifier, at?) true, visit or false, code; server resource np_legal only, after its legal.represent check. Prison validates custody, room, and slot rules; omitted at chooses the next free lawyer slot.
AddTime(who, months, reason) true or false, code
ReduceTime(who, months, reason) true or false, code. Never below the months served; zero left releases the inmate
GetInmates(facility?) Sentence[]: every jailed inmate, online or not
GetBehaviour(who) number (0–100)
AddBehaviour(who, delta, reason) The new value
AddAccount(who, amount, reason) added, overflow: money on the inmate account, capped at Config.Account.cap
GetFacilities() { { id, label, short, kind, icon, tint, capacity, cells, security } }
GetAlertLevel(facility) 'quiet', 'suspicious', 'siren' or 'manhunt'
SetAlertLevel(facility, level, reason, actor?) true or false, code; player-initiated calls can pass the actor server ID and are permission-checked
GetRecords(who, limit?) { { id, ts, actor, kind, amount, reason, data } }, newest first
GetCriminalRecord(who) CriminalRecord or nil
registerHook(name, fn, opts?) Hook id. See Hooks
removeHook(id) boolean

np_jobs and pack-facing exports ​

The optional np_jobs bridge asks pack-owned features for booking, release, sentence, transfer, judge, and lawyer actions. Unknown or offline features use the existing job/permission fallback; a live feature denial is enforced. Protected staff actions require duty in both paths. np_prison remains a normal resource and registers no feature pack. Current police.booking, police.transport, legal.judge, and legal.represent mappings are available from the neighboring pack contracts; proposed police.corrections.* extensions fall back until np_police registers them.

New server exports give packs a structured API while the PascalCase APIs above remain compatible:

Export Use
getPenalCode() / computeSentence(charges, modifiers?) Read the configured code and reuse the server calculator. Penal-code authoring/population remains deferred.
bookInmate(targetSrc, opts) / getInmate(who) Book with actor/case metadata and query a current booking.
adjustSentence(who, deltaMonths, opts?), releaseInmate(who, opts?), transferInmate(who, facility, opts?) Mutate an existing custody record; pass opts.actor for player-initiated actions.
getVisitSlots(whoOrFacility, kind?), bookVisit(who, at, opts) Query and book family or lawyer visitation; lawyer visits check legal.represent or the on-duty legacy lawyer job.
requestTrial(who, opts?), getGuards(facility?) Emit a trial request for np_legal and query on-duty correction staff.

Additive server-local events include np_prison:booked, :transferred, :trialRequested, :visitBooked, :visitStarted, :visitEnded, and :guardShift. Existing event names and payloads remain unchanged. Prison work details are planned to move to np_minijobs under category prison; no migration is part of this integration. See the np_jobs resource integration guide and the full integration contract.

Sentence ​

lua
{ identifier, name, source = src | nil, facility, cell, security, monthsTotal, monthsServed, monthsLeft,
  behaviour, account, bookedAt, bookedBy, number, bookingId }   -- number is the public six-digit inmate number; bookingId identifies current custody

CriminalRecord ​

lua
{ identifier, name, number, status, jailed, monthsLeft, bookings, escapes, totalMonths, lastBooked, warrants,
  entries = { { ts, kind, amount, reason } } }        -- entries newest first

For MDTs and ID checks. warrants counts a bail no-show and an escape.

Modules ​

Export Module Returns
GetEscapees(facility?) breakouts { { identifier, name, source, facility, route, escapedAt, detected, wantedUntil, bounty } }: everyone still wanted, oldest first
IsEscaped(who) breakouts boolean: broke out and is still wanted
TopUp(who, amount, fromSrc?) commissary true, charged or false, code. Money on an inmate's account from outside. With fromSrc the sender pays from their bank; without, your resource has charged them already. Only what fits under the cap is charged. Codes: not_jailed, invalid_params, account_full, topup_funds, no_player. Listed at the kiosk
GetPrisonSkills(who) activities { skills = { [skill] = xp }, certificates = { classId, … } } or nil. Kept after release
lua
-- a court resource books with its own reason and the judge as actor
local ok, res = exports.np_prison:JailPlayer(target, 36, 'bolingbroke', { reason = 'Case #2291', by = judgeName })
if not ok then print('booking failed: ' .. res) end

-- a family member's bank pays $200 onto an inmate's account
exports.np_prison:TopUp('char1:abc', 200, familySrc)

-- an MDT shows the record
local rec = exports.np_prison:GetCriminalRecord(citizenid)
if rec and rec.warrants > 0 then ... end

Client exports ​

client

Export Returns
IsJailed() boolean (the local player)
GetSentence() { facility, cell, security, monthsTotal, monthsServed, monthsLeft, behaviour, account } or nil
SkillCheck(opts) boolean; blocks. The shared ring: opts = { rounds, key, label, icon, tint, zone, speed }
OpenSentencing(target?) boolean. Opens the sentencing screen for a suspect's server id (nil = the nearest player). Police, guards and admins; the server checks again
lua
-- client: a police radial opens the sentencing screen
exports.np_prison:OpenSentencing(GetPlayerServerId(closestPlayer))

-- client: the ring for your own minigame
if exports.np_prison:SkillCheck({ rounds = { 'easy', 'medium' }, label = 'Pick the lock', icon = 'key' }) then ... end