Skip to content

cc_corrections: the jail API (contract v1)

cc_corrections is the prison. This contract replaces every DHS-PrisonSim call (SendPlayerToPrison, GetRemainingPrisonTime, ReleaseFromPrison). It covers server-side code only; a client cannot reach an

cc_corrections is the prison. This contract replaces every DHS-PrisonSim call (SendPlayerToPrison, GetRemainingPrisonTime, ReleaseFromPrison). It covers server-side code only; a client cannot reach any of it.

lua
if GetResourceState('cc_corrections') == 'started' then
    local ok, res = exports.cc_corrections:JailPlayer({ system = 'my_mdt', name = 'MDT' }, target, 30, 'Robbery', 'DC-00012')
end

Every export is pcall-safe and never raises. It returns ok, result where result is a table on success and a reason key string on failure. The reason keys are listed at the end.

Actors

Every call that changes something takes an actor as its first argument:

ActorAllowed when
{ system = '<resource>', name = 'Shown name' }system equals GetInvokingResource() and is listed in ServerConfig.Api.trustedSystems (server-only config). The list ships with cc_doj only: add your MDT, police job or staff panel
a player server id (number)JailPlayer: a police officer on duty (Config.PoliceJobs). Release: a corrections officer on duty with the earlyRelease grade, or a trusted system

A system actor whose name is missing is shown as the resource name. Every action is logged with the actor in the incident log (and on Discord, when the webhooks are set).

Exports

ExportReturnsNotes
JailPlayer(actor, target, months, reason, caseRef?)true, Inmate or false, reasontarget is an online server id. months is an integer from 1 to maxUnits (60), and one month is one real minute. The target is sent to prison now: contraband is seized as evidence, belongings are confiscated (ox_inventory ConfiscateInventory), they get a cell by classification, a prisoner number and the uniform. caseRef links the stay to a DOJ case. Refused when they are already inside (custody.already)
Release(actor, target, reason?)true or false, reasontarget is a server id or a citizenid, and works offline: the prisoner is walked to the gate on next login. Belongings wait at the property window
GetInmate(target)Inmate or nilServer id or citizenid. Returns nil when they are not inside (released, or never jailed)
IsJailed(target)booleantrue while in custody or due for release. false for an escapee (see Inmate.status)
GetRemainingMinutes(target)integer0 when not inside. This is the drop-in for DHS-PrisonSim's GetRemainingPrisonTime
courtSentence(cid, units, caseRef, judge)true or false, reasoncc_doj only: a verdict replaces the remand. Idempotent per case and length
bailPosted(cid, caseRef, amount)true or false, reasoncc_doj only: releases a prisoner on remand

The older exports (commit, remand, release, getPrisoner, isInCustody, getRemainingSeconds, ...) still work. New code uses the ones above. Since 1.5.0 the three that jail or free someone, commit, remand and release, answer false, 'api.actor' unless the calling resource (GetInvokingResource) is on ServerConfig.Api.trustedSystems, the same list the v1 system actors use, or on ServerConfig.Api.shimCallers (default: DHS-PrisonSim, the stand-in in compat/). The reads are unchanged.

courtSentence (and the pull of cc_doj's pending sentences) caps a sentence at cc_doj's GetSentenceLimits().maxMonths x Config.Doj.unitsPerMonth, never above maxUnits, and logs an incident when the cap bites. With cc_doj running, the legal-visit kiosk asks cc_doj IsLawyer (job or MDT practitioner register); Config.Doj.lawyerJobs is the fallback. A legal visit's outcome moves the cc_doj visitation item it filed (SetItemStatus): approved, completed, declined.

Since 1.6.0, additions only:

  • courtSentence(cid, units, caseRef, judge, opts?): optional 5th argument opts = { notified = true } (a bare true is accepted too) means the caller already told the defendant their sentence, so cc_corrections sends no notice. A row of cc_doj's pending-sentence list (GetPendingSentences) may carry the same notified = true. Without it, when cc_corrections jails or re-sentences the person itself, it sends one booking-in line (doj.you_were_sentenced: "You are booked into {prison}. Release in N minutes."), never a restatement of the sentence. JailPlayer sends no sentence notice, as before.
  • When Config.Doj.holdClock.resource names an MDT, cc_corrections reads its get export (GetHoldClock(citizenid) by default; pcall-guarded, only while that resource is started) and shows it at the booking: the reception queue rows and the desk menu rows carry hold = { state = 'running', minutes = N } | { state = 'expired' } | nil. cleared, nil, an error or a missing export show nothing. cc_corrections never computes the clock.

Since 1.6.1, additions only:

  • /remand calls the hold-clock MDT's start export (StartHoldClock(citizenid, officerName, officerSrc, { name })) after the committal is created, and courtSentence calls its clear export (ClearHoldClock(citizenid, why)) once the sentence is applied. Both only while that resource is started, pcall-guarded, silent on a missing export.
  • Net event cc_corrections:visit:desk(on) (CC.security.event, write cooldown, exclusive): sign on to or off the visitor desk. Duty and the visits permission are checked on the server. Snapshot: me.visitDesk, visits.desk (count), staff[i].visitDesk.

Inmate

lua
{
  citizenid = 'ABC12345', source = 12 | nil, name = 'Rory Kane', number = 'BP-000042',
  status = 'custody' | 'due' | 'ual', months = 30, secondsLeft = 1740, minutesLeft = 29,
  security = 'minimum' | 'medium' | 'maximum', cell = 'a_101' | nil,
  reason = 'Robbery', caseRef = 'DC-00012' | nil, remand = false, admittedAt = 1797000000,
}

Server events (local, never networked)

These are fired with TriggerEvent. Listen with AddEventHandler, never RegisterNetEvent. Check GetInvokingResource() == 'cc_corrections' before you trust one.

EventPayload
cc_corrections:jailedInmate plus by = actor name
cc_corrections:released{ citizenid, source?, number, name, reason, early, auto }
cc_corrections:escaped{ citizenid, source?, number, name }
cc_corrections:returned{ citizenid, source?, number, name }
cc_corrections:sentenceChangedInmate (a court verdict, remission or misconduct)

Reason keys

api.actor (the actor is not allowed), api.bad_args, committal.bad_target (target offline or unknown), committal.bad_units, custody.already, custody.not_in, custody.release_blocked (blocked by a hook), reception.no_cell (the prison is full), error.database, error.generic.

For the DHS-PrisonSim removal

DHS-PrisonSimcc_corrections
SendPlayerToPrison(src, secLevel, months)JailPlayer(actor, src, months, reason, caseRef?). The security level comes from the length (Config.Prison.classification, 30 and 50 months as the MDT uses)
GetRemainingPrisonTime(src) (minutes)GetRemainingMinutes(src)
ReleaseFromPrison(src)Release(actor, src, reason)

A drop-in stand-in, compat/DHS-PrisonSim, also exists in the cc_corrections repo. It is a resource named DHS-PrisonSim that answers those three calls by forwarding them here. Use it only if a caller cannot be edited.

Keep the map. If your prison interior came with DHS-PrisonSim (the Prompt prison MLO), DHS-PrisonSimAssets streams the cell-block props (djs_cellblock), and DHS-PrisonPeds streams the prisoner ped models. Removing DHS-PrisonSim itself is safe, but keep those two (or check the cells by eye with /corrections edit) so the cells are not left empty.