> For the complete documentation index, see [llms.txt](https://wiki.qfdevelopers.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.qfdevelopers.com/scripts/editor-22-1/additional-informations.md).

# Additional Informations

Page dedicated to Additional Informations about our DOJ MDT \[V2].

#### Core Features

* **Universal Framework Support:** Works with ESX, QBCore and QBox, detected automatically.
* **Court Cases:** Docket with parties, charges from your penal code, notes, evidence and a case timeline.
* **Warrants & Verdicts:** Warrants requested by staff and decided by a judge. Verdicts with fines, jail time, penalty points and licence suspensions.
* **Hearings:** Calendar per courtroom with attendance, outcomes and a warrant request for a no-show.
* **Court Papers:** Verdicts, warrants, summonses and your own templates printed as items, with the judge's signature and a code anyone can verify.
* **Court IDs:** One card with a serial per official, issued at the e-office and shown only to players who can actually see you.
* **Identity Documents:** ID cards, driving licences, weapon permits and residence cards with a photo from the booth, linked to your framework's licence flags.
* **Citizen E-Office:** Players read their own papers, cases and hearing dates, pay fines and ask for counsel at the courthouse counter.
* **Several Offices:** The bench, the prosecution and the defence on one tablet, each with its own ranks, colours, court ID and letterhead.
* **Police MDT \[V2] Bridge:** Charges filed in the police tablet open a DOJ case automatically.
* **Banking V2 Billing:** Optional penal code, fees and verdict fines through our [Banking \[V2\]](https://wiki.qfdevelopers.com/scripts/banking-v2.md).

***

#### Server Security

Every permission is checked on the server, not only hidden in the interface. Showing a court ID or a document is decided on the server too: the client only asks to show it, so a modified client cannot invent a card, put another name on it or show it across the map. The e-office answers only with the caller's own record.

***

#### Your Own Pictures

Office logos, card backgrounds, letterhead logos and seals live in the `artwork/` folder next to `fxmanifest.lua`. They are served as they are, so nothing has to be rebuilt: drop the file in, name it in the config without the folder (`"da.webp"`, `"offices/da.webp"`) and restart the resource. An https address works too. `/mdt doctor` lists every configured file that is missing.

***

#### Enforcing a Sentence

The tablet **records** sentences. It does not jail anyone or move money by itself, because every server does that differently. Two hooks in `config/server/editable.lua` are called with the finished decision:

```lua
function EDITABLE.OnVerdictIssued(verdict, defendantSource)
    -- verdict.outcome, verdict.fine, verdict.jailMonths, verdict.signature ...

    if defendantSource and verdict.jailMonths > 0 then
        exports['rcore_prison']:Jail(defendantSource, verdict.jailMonths * 30, verdict.signature)
    end

    if defendantSource and verdict.fine > 0 then
        EDITABLE.ChargePlayer(defendantSource, verdict.fine, verdict.signature)
    end
end

function EDITABLE.OnWarrantApproved(warrant, targetSource)
    -- warrant.type, warrant.targetId, warrant.validUntil ...
end
```

`defendantSource` and `targetSource` are `nil` when that player is offline, so always check them.

***

#### Developer API (Exports & Events)

{% tabs %}
{% tab title="Server Exports" %}
`identifier` is the character identifier your framework uses (`users.identifier` on ESX, `citizenid` on QBCore and QBox). Every export checks its input and answers an empty result or `nil, errorKey` instead of raising an error.

**Court**

| Export                               | Description                                                                                                                                             |
| ------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `getActiveWarrants(identifier)`      | Approved warrants still in force, newest first.                                                                                                         |
| `hasActiveWarrant(identifier, type)` | `true` or `false`. `type` is optional and comes from `Config.Warrants.types`.                                                                           |
| `getCitizenRecord(identifier)`       | Summary (open cases, convictions, unpaid fines, active warrants) with the last cases, verdicts and warrants. No ruling text.                            |
| `createCase(data)`                   | Opens a case: `title` (required), `type`, `status`, `description`, `defendantId`, `defendantName`, `charges`, `sourceRef`. Returns `caseId, signature`. |
| `RevokeCourtId(identifier)`          | Voids an official's court ID, for servers that dismiss staff in another resource.                                                                       |

```lua
if exports.qf_mdt_doj_v2:hasActiveWarrant(citizenId, 'arrest') then
    -- flag the person at a traffic stop
end

local caseId, signature = exports.qf_mdt_doj_v2:createCase({
    title = 'Armed robbery',
    defendantId = citizenId,
    charges = { { code = 'P-201', count = 1 } },
    sourceRef = reportId, -- the same sourceRef never opens a second case
})
```

**Identity documents**

| Export                                             | Description                                                                    |
| -------------------------------------------------- | ------------------------------------------------------------------------------ |
| `getIdentityDocuments(identifier)`                 | Documents of a citizen.                                                        |
| `hasValidIdentityDocument(identifier, kind)`       | Whether the citizen holds a valid document of that kind.                       |
| `canIssueIdentityDocument(identifier, kind)`       | Runs the checks of the counter without issuing anything.                       |
| `issueIdentityDocument(identifier, kind, options)` | Issues a document, for example a driving licence after a passed test.          |
| `getIdentityPoints(identifier)`                    | Current penalty point balance.                                                 |
| `addIdentityPoints(identifier, points, options)`   | Adds points. Pass `options.sourceRef` so a repeated call is not counted twice. |
| `checkIdentityCode(source, code)`                  | Checks the code printed on a card, for example from your police tablet.        |
| `seizeIdentityDocument(source, code, reason)`      | Seizes a document by its code.                                                 |

**Dispatch, staff and logs**

| Export                                                               | Description                                                                                       |
| -------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `CreateCall(data)`                                                   | Raises a request on the board: `title` and `coords` required, `code`, `priority`, `job` and more. |
| `CreateCitizenCall(source, data)`                                    | Same as above, raised by a player. Position and caller name are taken from the player.            |
| `CloseCall(callId, reason)`                                          | Closes a request.                                                                                 |
| `AddLog(source, tag, text, color, fields, args, caseId)`             | Adds an entry to the Audit Log.                                                                   |
| `GetOfficerBadge(identifier)` / `SetOfficerBadge(identifier, badge)` | Reads or sets an official's badge number.                                                         |
| `GetOfficerHours(identifier)`                                        | Hours on duty.                                                                                    |
| `RefreshOfficer(identifier)`                                         | Rereads badge, grade and radio of an online official.                                             |
| `GetPoliceBridgeStatus()`                                            | Whether the Police MDT bridge is enabled and active.                                              |

```lua
local callId = exports.qf_mdt_doj_v2:CreateCall({
    title = 'Lawyer requested',
    code = '10-50',
    coords = GetEntityCoords(GetPlayerPed(source)),
    priority = 'medium',
    job = 'doj',
})

exports.qf_mdt_doj_v2:CloseCall(callId, 'resolved')
```

{% endtab %}

{% tab title="Server Events" %}
Local server events (`AddEventHandler`), never sent to clients. Dates are unix seconds.

| Event                             | When it fires                                                                                                                                  |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `qf_mdt_doj_v2:verdictIssued`     | After a verdict is stored and `EDITABLE.OnVerdictIssued` ran.                                                                                  |
| `qf_mdt_doj_v2:verdictVacated`    | Once per vacated verdict.                                                                                                                      |
| `qf_mdt_doj_v2:warrantApproved`   | After `EDITABLE.OnWarrantApproved`.                                                                                                            |
| `qf_mdt_doj_v2:warrantExpired`    | Once per warrant, from the expiry check.                                                                                                       |
| `qf_mdt_doj_v2:hearingScheduled`  | When a hearing is put in the calendar, and again with `rescheduled = true` when moved.                                                         |
| `qf_mdt_doj_v2:identityDocument*` | On every change of an identity document: `Issued`, `Renewed`, `Suspended`, `Restored`, `Revoked`, `Expired`, `Replaced`, `Seized`, `Reported`. |

```lua
-- A prison resource
AddEventHandler('qf_mdt_doj_v2:verdictIssued', function(verdict)
    if verdict.outcome == 'conviction' and verdict.jailMonths > 0 then
        -- jail verdict.defendantId
    end
end)
```

{% endtab %}

{% tab title="Client Exports" %}
Each acts on the local player's screen only.

| Export                               | Description                                                                     |
| ------------------------------------ | ------------------------------------------------------------------------------- |
| `openCitizenPortal()`                | Opens the citizen e-office, for servers with `Config.Portal.spawnPeds = false`. |
| `openIdentityStudio()`               | Opens the photo booth at the nearest studio location.                           |
| `openIdentityForgery()`              | Opens the forgery panel when `Config.Identity.forgery` is enabled.              |
| `showOfficerBadge(card, duration)`   | Shows a court ID card built by the calling resource.                            |
| `showDispatchAlert(data)`            | Shows the popup for a request. Create real requests with `CreateCall`.          |
| `GetMugShotBase64(ped, transparent)` | Renders a mugshot of the ped and returns it as a base64 string.                 |

```lua
exports.qf_mdt_doj_v2:showOfficerBadge({
    name = "Richard Whitaker",
    badge = "DOJ-04",
    gradeLabel = "Judge",
    title = "Presiding Judge",
    mugshot = "https://example.com/photo.png", -- optional
})
```

{% endtab %}

{% tab title="Editable Hooks" %}
`config/server/editable.lua` and `config/client/editable.lua` hold the functions that talk to the rest of your server. They stay open after escrow and are meant to be edited.

Frequently changed hooks:

| Hook                                                            | Purpose                                                        |
| --------------------------------------------------------------- | -------------------------------------------------------------- |
| `EDITABLE.OnVerdictIssued(verdict, defendantSource)`            | Jail time and fines in your prison and billing resources.      |
| `EDITABLE.OnWarrantApproved(warrant, targetSource)`             | What an approved warrant does on your server.                  |
| `EDITABLE.GetName(identifier)`                                  | How a citizen's name is resolved from your database.           |
| `EDITABLE.GetBadge(xPlayer)`                                    | Badge number shown on the court ID.                            |
| `EDITABLE.GetPlayerLicenses` / `GiveLicense` / `RevokeLicense`  | Where licences are read and written.                           |
| `EDITABLE.GetBankBalance` / `ChargePlayer` / `RefundIdentifier` | How fines and fees are charged and refunded.                   |
| `EDITABLE.AddMoneyToSociety(amount, jobName)`                   | Where the court's share of a payment goes.                     |
| `EDITABLE.CreateBilling(...)`                                   | Bridge into your billing resource.                             |
| `EDITABLE.GiveCodedItem` / `RemoveCodedItem` / `HasCodedItem`   | Adapter for an inventory that is not supported out of the box. |
| `EDITABLE.OnStatusChange(source, status)`                       | Fired when an official goes on or off duty.                    |
| `EDITABLE.CanOpenMDT()` (client)                                | Extra conditions before the tablet may open.                   |

**Discord logs**

Every Audit Log entry can be copied to a Discord webhook. The webhook lives in `EDITABLE.Logs` in `config/server/editable.lua` on purpose: `config/config.lua` is sent to every client, and a webhook address is a secret.

```lua
EDITABLE.Logs = {
    enabled = true,
    username = "MDT DOJ",
    default = "https://discord.com/api/webhooks/...",
    routes = {
        { match = "verdict_",  url = "https://discord.com/api/webhooks/..." },
        { match = "identity_", url = "" },
    },
}
```

{% endtab %}
{% endtabs %}

***

#### Frequently Asked Questions (Q\&A)

**Q: The tablet does not open at all.**\
A: Check that the player's job is in `Config.Jobs` and that their grade exists in `Config.Grades`. Run `/mdt doctor` for a full configuration check.

**Q: The court ID item does nothing or shows somebody else's card.**\
A: With `Config.Badge.item.mode = "owner"` every official carries their own card with a serial number, so a stolen card always shows its owner. The item `qf_mdt_doj_v2_badge` must exist in your inventory. With `Config.Badge.issue = "portal"` the card is applied for and collected at the e-office.

**Q: Verdicts do not jail anybody.**\
A: The tablet records the sentence only. Connect your prison in `EDITABLE.OnVerdictIssued` or listen to `qf_mdt_doj_v2:verdictIssued` (see [Enforcing a Sentence](#enforcing-a-sentence)).

**Q: My penal code changes in the config are ignored.**\
A: The seed is imported only once, into an empty table. After that the penal code is edited in the tablet. Set `Config.PenalCode.reseedOnStart = true` for one restart to import it again, then turn it back off.

**Q: The photo booth does not open.**\
A: It needs `screenshot-basic` running. Without it cards carry the mugshot the MDT already stores (`Config.Identity.photoFallback`).

**Q: Players' existing licences disappeared after installing.**\
A: They did not. The identity module never touches a licence it did not set and does no bulk sync. A player who holds a licence without a card can apply for one, or use `Config.Identity.transition` to let them collect it for free for a while.

**Q: Police charges do not appear as DOJ cases.**\
A: Check `exports.qf_mdt_doj_v2:GetPoliceBridgeStatus()`. The bridge needs `qf_mdt_police_v2` running, and `Config.PoliceBridge.tables` must match the police `Config.Base` if you renamed its tables. Charges without jail time are skipped unless `importFineOnlyCharges = true`.

**Q: Requests appear twice on screen.**\
A: Another dispatch resource is drawing them as well. Set `Config.Dispatch.ShowOnScreenAlerts = false`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://wiki.qfdevelopers.com/scripts/editor-22-1/additional-informations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
