Koja Scripts

Departments and permissions

How to add departments, map jobs and grades to access levels, and what every permission key allows.

Departments and permissions

Every faction that uses the MDT is one entry in Config.Departments in shared/departments.lua. A player's framework job decides which department they belong to. That department sets their permissions, crest and tablet theme. Adding a faction needs no code.

A job that is not listed in any department has no MDT access. A job may appear in only one department.

Department fields

FieldRequiredDescription
labelyesFull name, shown on papers, mail and the roster.
shortyesShort tag such as LSPD. Shown in the top bar, on badges and in document numbers. Defaults to the id in upper case.
jobsyesFramework job names that belong to this department.
typeyesleo, doj, ems, fire or other. Aliases: police and sheriff become leo, medical and ambulance become ems, justice becomes doj. Anything else becomes other.
colornoDepartment color (hex). Used for unit dots, tags and the tablet accent.
logonoA built-in crest key or an image URL (https://..., nui://...).
mottonoPrinted on citations and forms.
callsignPrefixnoPrefix for automatic callsigns, for example 1-.
citationPrefixnoCitation number prefix. Config.Citations.prefixes[id] takes precedence.
themenoTablet look. A string works as a preset: theme = 'ems'.
ranksno[minGrade] = accessLevel. The highest minGrade at or below the player's grade wins.
bossRanknoAccess level for boss grades.
defaultRanknoUsed when no ranks entry matches.
jobRanksno[jobName] = accessLevel. Fixes the level for one job regardless of grade. DOJ uses it for lawyer, da, clerk and judge.
permissionsno[accessLevel] = { 'perm', ... } or [accessLevel] = 'presetName'. Gives this department its own permission list for a level.
statusesnoOwn unit status list { id, code, color }, replacing the default list for this department.
fieldnotrue or false. Field departments can go on duty, appear on the unit board and live map, and receive dispatch calls. Defaults to true for leo, ems and fire.

Departments missing from Config.DepartmentOrder are added at the end in alphabetical order, so the order list is optional.

Adding a department

  1. Add the entry

    shared/departments.lua
    lsfd = {
        label = 'Los Santos Fire Department',
        short = 'LSFD',
        type = 'fire',
        jobs = { 'fire', 'firefighter' },
        color = '#F97316',
        logo = 'fire',
        motto = 'Courage and Honor',
        callsignPrefix = 'F-',
        theme = 'fire',
    },
  2. Add it to the order list (optional)

    shared/departments.lua
    Config.DepartmentOrder = { 'lspd', 'bcso', 'sahp', 'doj', 'ems', 'lsfd' }
  3. Restart the resource

    Players with one of the listed jobs now see the MDT with the new department.

A custom faction with its own permissions:

shared/departments.lua
rangers = {
    label = 'San Andreas Park Rangers',
    short = 'SAPR',
    type = 'other',
    field = true,
    jobs = { 'ranger' },
    color = '#22C55E',
    logo = 'https://example.com/rangers.png',
    theme = { preset = 'custom', accent = '#22C55E', surface = '#0c1510' },
    ranks = { [0] = 'ranger', [4] = 'chief' },
    bossRank = 'chief',
    permissions = {
        ranger = { 'dashboard.view', 'roster.view', 'mail.use', 'calendar.view', 'dispatch.view', 'citizens.view' },
    },
},

You can also create and edit departments live from the Admin panel when Config.Admin.departmentOverrides is on. Changes from the panel are stored in the database table koja_mdt_department_overrides and merged over the file.

Ranks and access levels

A department maps framework grades to an access level. The access level decides the permission set.

LevelMeant for
cadet, officer, supervisor, commandLaw enforcement. command has every permission except admin.manage.
defense, prosecutor, clerk, judgeDOJ.
responder, responder_lead, responder_chiefEMS and fire.
member, lead, chiefOther factions (non-field by default).

Default ranks by type, used when a department does not define its own:

TypeDefault
leo[0] = 'cadet', [1] = 'officer', [3] = 'supervisor', [5] = 'command'
doj[0] = 'defense', [1] = 'prosecutor', [2] = 'clerk', [3] = 'judge'
ems, fire[0] = 'responder', [3] = 'responder_lead', [5] = 'responder_chief'
other[0] = 'member', [3] = 'lead', [5] = 'chief'

How the level is resolved for a player:

  1. If the department has jobRanks[job], that level is used.
  2. If the player is a boss grade, bossRank is used. Defaults: leo is command, ems and fire are responder_chief, other is chief.
  3. Otherwise the ranks entry with the highest minGrade at or below the grade is used.
  4. If nothing matches: defaultRank, then cadet (leo), defense (doj), responder (ems, fire) or member.

What each level can do

LevelSummary
cadetView the main record pages, create reports and evidence, view, create and print citations.
officerCadet plus edit people, vehicles, firearms and reports, process suspects, request warrants, create BOLOs, manage dispatch, view cameras and bodycams, view custody and create impounds.
supervisorOfficer plus revoke licenses, restricted and deletable reports, delete warrants, BOLOs and evidence, manage bulletins, view logs, review forms, discipline, manage the calendar, void citations, watch and manage bodycams, manage jail and release impounds.
commandEvery permission except admin.manage.
defenseCourt view, bar registry view, expungement requests, people and report view, charges, bulletins, mail, forms and calendar.
prosecutorDefense plus case management, vehicles, firearms, warrants view, evidence view, roster view, citations view, bodycams view and jail view.
clerkDefense plus case management, hearing scheduling, bar registry management, warrants view, roster view, citations view, forms review, calendar management and jail view.
judgeProsecutor plus approve and delete warrants, restricted reports, manage charges and bulletins, view logs, review forms, mail broadcasts, manage calendar, void citations, schedule hearings, rule on cases, review expungements, manage the bar registry.
responderDashboard, roster, mail, calendar, bulletins, divisions, certifications, forms, dispatch view. EMS departments also get the medical permissions.
responder_leadResponder plus dispatch management, bulletins and calendar management, form reviews, logs, discipline.
responder_chiefLead plus hire and fire, suspend, manage divisions, certifications and forms, mail broadcasts.
member, lead, chiefThe same as the responder levels without dispatch.

The default EMS and fire levels do not include citizens.view or incidents.view because those pages show criminal records. Add them through permissions if your server wants medics to see them.

Every permission is checked on the server for each request. The interface only hides what the player cannot use. Pages without permission are hidden from the navigation, and opening them directly shows a no permission screen.

Permission list

Permission keys are written in the form page.action. Players hold permissions through their access level.

People, vehicles and records

PermissionAllows
dashboard.viewOpen the dashboard.
citizens.viewView people and their files.
citizens.editEdit a person's file, flags and photos.
licenses.revokeRevoke and reinstate licenses.
vehicles.viewView and search vehicles.
vehicles.editEdit vehicle flags and notes.
weapons.viewView the firearm registry.
weapons.editRegister and edit firearms.
incidents.viewView reports.
incidents.createWrite reports.
incidents.editEdit reports.
incidents.deleteDelete reports.
incidents.restrictedView restricted reports.
incidents.processProcess suspects (fine, jail, points).
charges.viewView the penal code.
charges.manageEdit the penal code.

Warrants, BOLOs, evidence

PermissionAllows
warrants.viewView warrants.
warrants.createRequest or create warrants.
warrants.approveApprove or deny pending warrants (judges).
warrants.deleteDelete warrants.
bolos.viewView BOLOs.
bolos.createCreate BOLOs.
bolos.deleteDelete BOLOs.
evidence.viewView the evidence locker.
evidence.createAdd evidence.
evidence.deleteDelete evidence.

Dispatch, citations, custody

PermissionAllows
dispatch.viewView calls and the unit board.
dispatch.manageCreate, assign and close calls.
citations.viewView citations.
citations.createWrite citations.
citations.printPrint citations as an item.
citations.voidVoid citations and resolve contests.
jail.viewView jail records.
jail.manageRelease early, change terms, transfer.
impound.viewView impounds.
impound.createImpound vehicles.
impound.releaseRelease impounded vehicles.

Court and DOJ

PermissionAllows
court.viewView the docket.
court.manageFile and edit cases, charges and links.
court.scheduleSchedule hearings.
court.ruleVerdicts, sentences, carrying out a sentence.
expunge.requestRequest expungement.
expunge.reviewDecide expungement requests.
bar.viewView the bar registry.
bar.manageManage the bar registry.

Staff, communication, surveillance

PermissionAllows
bulletins.viewView bulletins.
bulletins.manageCreate and edit bulletins.
roster.viewView the employee list.
roster.manageHire, fire, promote and demote.
roster.disciplineGive rewards and strikes.
roster.suspendSuspend and reinstate members.
logs.viewView the audit log.
mail.useUse internal mail.
mail.broadcastSend mail to whole departments.
divisions.viewView divisions.
divisions.manageCreate and edit divisions.
certifications.viewView certifications.
certifications.manageCreate certifications, assign and revoke.
forms.viewView and fill forms.
forms.manageBuild forms.
forms.reviewApprove or reject submissions.
calendar.viewView the calendar.
calendar.manageCreate and edit events.
cameras.viewWatch CCTV cameras.
cameras.manageManage cameras.
bodycams.viewView bodycam sessions.
bodycams.watchWatch bodycams live.
bodycams.manageManage bodycam sessions.
admin.viewView the Admin panel.
admin.manageChange things in the Admin panel. Not part of command; given through the koja-mdt.admin ace or explicitly.

Medical

Only granted to ems departments, or through permissions in other departments.

PermissionGranted to
patients.view, patients.edit, treatments.view, treatments.create, hospital.view, hospital.manage, bills.view, bills.createresponder and up
treatments.edit, bills.voidresponder_lead and up
treatments.deleteresponder_chief
patients.summaryRead-only medical summary on the People page. Granted to police access levels listed in Config.Ems.policeSummary.ranks, only when Config.Ems.policeSummary.enabled = true. Every view is logged.

Bodycams and CCTV cameras without a department list also require a law enforcement department.

Boss grades

Boss grades come from the framework (the boss flag of the job grade). A boss in a department gets its bossRank instead of the grade based level. Set bossRank explicitly if the default does not suit you. jobRanks takes precedence over the boss rule.

Custom permission lists

Use permissions in a department to override one level:

shared/departments.lua
permissions = {
    officer = 'supervisor',                 -- use another preset for this level
    cadet = { 'dashboard.view', 'mail.use' } -- or an explicit list
}

Unknown keys are ignored. The Admin panel can also edit these lists per department.

Themes and logos

logo accepts these built-in crests: lspd, bcso (also sheriff, star), sahp (trooper, wings), doj (justice, scales), ems (medical, ambulance), fire (lsfd, maltese), shield (police). Unknown keys use the generic shield. Any https:// or nui:// image URL also works.

theme switches the tablet look:

shared/departments.lua
theme = { preset = 'bcso' }
theme = { preset = 'custom', accent = '#22C55E', surface = '#0c1510' }
theme = { preset = 'ems', accent = '#F43F5E' }
PresetLook
lspd / neutralDefault neutral dark tablet with the department color as accent.
bcsoWarm tan and olive dark surfaces.
sahpCool steel blue dark surfaces.
dojDeep burgundy charcoal.
emsDark red tinted surfaces.
fireDark ember red and orange surfaces.
customNothing preset. Only your accent and surface apply.
  • accent is the highlight color (buttons, active tabs, toggles). Defaults to color.
  • surface is the base screen color (hex). All other surfaces are derived from it. Keep it dark, roughly #0e0e10 to #221012.

If theme is omitted, the preset is picked from the department id, then from logo, then from type. A player's personal accent (Settings, when Config.Ui.allowPersonalAccent is on) overrides the accent but not the surfaces.

DOJ

Court options live in Config.Doj. Parties assigned to a case (judge, prosecutor, defense) can add docket filings and link records even without court.manage. Carrying out a sentence uses the fine and jail adapters in editable/server/integrations.lua. See Integrations.

Dispatch for EMS and fire

Field departments receive calls that target them. Calls with no target go to law enforcement only. Create calls from your own scripts with the server export, see Server exports. Calls created from the MDT by a non-police department are sent to that department.