Browse docs

Server: Jail

Server exports for jail locations, sentencing, release and remaining time, with external MDT integration examples.

All exports

These exports are an optional developer integration for an external MDT such as LB Tablet. Call them from a server script after sky_policejob and its jail locations have loaded. A separate bridge resource should declare dependency "sky_policejob" in its fxmanifest.lua.

Configure a jail with an intake spawn and a release location before accepting sentences. Use getJails() below to obtain its actual ID; a jail's display name is not its ID. With Job Configurator enabled, its saved settings and Jail Creator locations are the effective values.

The calling server resource must authorize the officer and target before sentencing or releasing anyone. These integration calls do not require a Police job, duty status, officer proximity or a jail terminal. Do not forward arbitrary client requests directly into them. Existing Police menu and command authorization is unchanged.

getJails()

Returns an array of configured jail locations, sorted by name. Each entry contains:

FieldMeaning
idStable jail ID to pass to jailPlayer
nameDisplay name
spawnIntake coordinates, or absent if not configured
releaseLocationJail release coordinates, falling back to the configured global release location; absent if neither is set
solitaryCellCountNumber of configured solitary cells with coordinates
terminalConfiguredWhether the jail has at least one configured terminal
terminalNearbyfalse when called without an acting player

The returned tables are copies. An empty array means no jail locations are currently loaded; finish configuring/loading the jail before enabling sentencing in your bridge.

-- Server-side setup: inspect the available locations and choose the intended ID.
for _, jail in ipairs(exports["sky_policejob"]:getJails()) do
    print(jail.id, jail.name)
end

jailPlayer(playerId, time, unit, jailId)

Creates a sentence through the same server intake used by Sky Police Job. It saves the custody record, applies configured inventory confiscation and job removal, teleports the player to the jail spawn, and starts the normal jail HUD, outfit and activities. This external intake skips the officer mugshot sequence. Reconnect recovery and automatic release use Sky's saved sentence.

This call can yield while saving the sentence. Call it from a scheduled server context such as your MDT's existing server callback or event handler, and inspect its returned result.

ArgumentTypeMeaning
playerIdnumberOnline player's server ID, with a loaded character
timenumberPositive, finite sentence duration
unitstringExactly "seconds", "minutes" or "months"
jailIdstringA configured id returned by getJails()

Seconds and minutes are real time. Months use the effective Jail.monthMinutes setting; with the default of 15, two months equal 30 real minutes. Fractional durations round up to the next whole second. The maximum accepted duration is 2,147,483 seconds. Explicit export durations are not clamped to the jail menu's minMonths/maxMonths selection limits, so a five-minute external sentence remains five minutes.

Returns { success = true } after intake succeeds, or { success = false, error = "reason" }. An already imprisoned player returns already_imprisoned; the export does not replace or extend their existing sentence.

-- Inside your MDT's authorized server-side sentencing handler.
-- Replace this placeholder with an ID returned by getJails().
local jailId = "YOUR_JAIL_ID"
local result = exports["sky_policejob"]:jailPlayer(playerId, 30, "minutes", jailId)
if not result.success then
    print(("Jail assignment failed: %s"):format(result.error))
    return
end
-- Only now confirm successful sentencing to your MDT.
ErrorMeaning
disabledJail intake is disabled
invalid_targetInvalid/offline player ID, unavailable character, or character changed during intake
invalid_unitUnit is not one of the three supported strings
invalid_timeDuration is not positive/finite or exceeds the maximum
invalid_configurationThe effective month-to-minute conversion is not positive and finite
jail_not_foundJail ID is missing, invalid or not loaded
already_imprisonedThe player already has an active sentence
spawn_not_setThe selected jail has no intake spawn
release_not_setNeither the selected jail nor the global jail settings has a release location
failedThe custody booking could not be saved

unjailPlayer(playerId)

Releases an online prisoner through Sky's normal release path. It uses their sentence's release location, attempts to return confiscated items through the configured inventory adapter, restores the prior job when configured, ends the jail HUD/outfit state, and finalizes the saved custody record. Items the inventory cannot accept remain saved for later property return. Pending intake mugshot timers are cancelled. This is an early/manual release, equivalent to admin unjail; it does not mark linked offences as automatically served.

Returns { success = true }, or { success = false, error = "invalid_target" | "not_imprisoned" }. A repeated release returns not_imprisoned and does not return inventory twice. Release remains available if new jail intake has been disabled. The player and their ped must be available; an unavailable target returns invalid_target without ending the sentence. This call can yield while restoring saved data.

-- Inside your MDT's authorized server-side release handler.
local result = exports["sky_policejob"]:unjailPlayer(playerId)
if not result.success then
    print(("Jail release failed: %s"):format(result.error))
    return
end

getRemainingJailTime(playerId)

Returns the remaining sentence as a non-negative integer in real seconds, rounded up. Returns 0 when there is no active in-memory sentence for this server ID, including an offline player or a character whose saved sentence has not been restored yet. It does not look up offline characters by identifier. An expired timer also returns 0 while normal automatic release finishes.

local remainingSeconds = exports["sky_policejob"]:getRemainingJailTime(playerId)
local remainingMinutes = math.ceil(remainingSeconds / 60)

isPlayerInPrison(playerId)

Returns boolean: whether the server ID currently has an active in-memory jail entry. This existing export remains available and does not query offline records.

local imprisoned = exports["sky_policejob"]:isPlayerInPrison(playerId)

Connecting LB Tablet or another MDT

These exports supply the Sky side of a custom jail integration. They do not automatically install or select an LB Tablet bridge. In your installed MDT's editable server-side jail integration:

  1. Use getJails() to select a configured jail ID and save that ID in your bridge configuration.
  2. After the MDT authorizes a sentence, call jailPlayer with the MDT's actual time unit. Check result.success before confirming the action in the MDT.
  3. Route the MDT's authorized unjail action to unjailPlayer and check its result.
  4. Read Sky's countdown with getRemainingJailTime; convert seconds only if your MDT expects another unit. Sky owns sentence progression, reconnect recovery and automatic release.
  5. Configure the MDT's jail provider so the same action does not also run another jail resource or a second independent release timer.

Use the hooks documented for your installed MDT version. The examples above show Sky calls, not LB-specific hook names. To verify the integration, assign a short sentence, check that the countdown decreases, reconnect, then test both manual release and release when the timer expires.