π§© EditTable β Complete Reference
TheEditTable is the heart of XR-MDT customization. It is a globally accessible Lua table that exposes every integration point the script offers β from money handling and database queries to dispatch routing and job-specific logic. Because XR-MDT is Tebex Escrow-protected, you cannot modify core files β but you can modify everything inside the editable/ folder, and the EditTable is the bridge that connects your custom code to the protected core.
π What is the EditTable?
| Concept | Explanation |
|---|---|
| Purpose | A global Lua table (EditTable) that holds all editable functions, events, and queries the MDT core calls at runtime. |
| Location | Defined across files in editable/server/ and editable/client/. |
| How it works | The core (escrowed) code calls EditTable.Events.RemoveMoney(...) instead of directly calling a framework function. You control what happens inside that function. |
| Safety | Modifying EditTable functions never breaks escrow β the core only reads from it. |
[!IMPORTANT]
Every EditTable function listed below is fully editable. Override any of them to adapt XR-MDT to your serverβs custom scripts, frameworks, or databases.
π File Structure
[!NOTE] Load order matters.editable/server/main.luais loaded first among all editable files, so theBridgeandEditTabletables are available whenlspd.lua,ems.luaetc. are loaded.
π§ Server β Core Module (editable/server/main.lua)
This is the main bridge between XR-MDT and your framework. It contains:
- Framework detection and object initialization (
QBCore,ESX). - The
Bridgeabstraction layer for all framework operations. EditTable.Eventsβ the primary integration points called by the core.EditTable.Functionsβ utility helpers.- Event listeners for dispatch and notifications.
Bridge Functions
TheBridge table provides a framework-agnostic API. These functions are used internally by EditTable and by editable/server/lspd.lua, ems.lua, etc.
Player & Job
| Function | Signature | Description |
|---|---|---|
Bridge.GetPlayer | (source) β player | Returns the raw framework player object. |
Bridge.GetJob | (source) β job | Returns the playerβs current job table (normalized for ESX). |
Bridge.GetCitizenId | (player) β string | Returns the playerβs unique identifier (citizenid / identifier). |
Bridge.GetCitizenIdFromObject | (player) β string | Same, but from the player object directly. |
Bridge.GetCharInfo | (player) β table | Returns { firstname, lastname, phone }. |
Bridge.GetCitizenName | (citizenId) β string | DB lookup β returns "Firstname Lastname" for a citizenId. |
Bridge.GetSource | (player) β number | Returns the server source ID from the player object. |
Bridge.GetMetaData | (player, key) β any | Gets a metadata value from the player. |
Bridge.SetMetaData | (player, key, value) | Sets a metadata value on the player. |
Bridge.IsOnDuty | (player) β boolean | Returns true if the player is on duty. |
Bridge.GetPlayerByCitizenId | (citizenId) β player? | Finds an online player by their citizenId. Returns nil if offline. |
Bridge.GetPlayers | () β table | Returns all online player objects. |
Bridge.GetJobFromObject | (player) β job | Returns the job table directly from the player object. |
Money
| Function | Signature | Description |
|---|---|---|
Bridge.GetMoney | (source, type) β number | Gets the playerβs account balance. type: 'cash' or 'bank'. |
Bridge.AddMoney | (source, type, amount) β boolean | Adds money to the playerβs account. |
Bridge.RemoveMoney | (source, type, amount) β boolean | Removes money from the playerβs account. Returns false if insufficient. |
Bridge.DeductMoneyByCitizenId | (citizenId, type, amount, reason) β boolean | Deducts money by citizenId (handles both online and offline players). |
Banking (Society)
| Function | Signature | Description |
|---|---|---|
Bridge.Bank.GetBalance | (accountName) β number | Gets a society/business account balance. |
Bridge.Bank.AddMoney | (accountName, amount, reason?) β boolean | Deposits into a society account. Also records in bank_statements. |
Bridge.Bank.RemoveMoney | (accountName, amount, reason?) β boolean | Withdraws from a society account. Also records in bank_statements. |
Items & Inventory
| Function | Signature | Description |
|---|---|---|
Bridge.GetItem | (source, item) β table? | Returns item data from the playerβs inventory. |
Bridge.GetItemCount | (source, item) β number | Returns the quantity of an item the player has. |
Bridge.AddItem | (source, item, count, slot?, metadata?) β boolean | Adds an item to the playerβs inventory. |
Bridge.RemoveItem | (source, item, count, slot?) β boolean | Removes an item from the playerβs inventory. |
Bridge.RegisterUsableItem | (name, handler) | Registers a usable item. Uses ox_inventory:registerHook when available. |
Job Management
| Function | Signature | Description |
|---|---|---|
Bridge.SetJob | (player, job, grade) | Changes the playerβs job. |
Bridge.SetJobDuty | (player, state) | Sets the playerβs duty state (on/off). |
Bridge.Save | (player) | Forces a player data save (QB). |
Bridge.JailPlayer | (source, time) | Sends a player to jail via the detected jail resource. |
Bridge.UpdateVehicleOwner | (plate, targetCitizenId) β number | Transfers vehicle ownership in the DB. |
UI & Interaction
| Function | Signature | Description |
|---|---|---|
Bridge.Notify | (source, text, type, length) | Sends a notification to a player. |
Bridge.RegisterCommand | (name, help, arguments, restricted, handler) | Registers a command (QB uses QBCore.Commands.Add, ESX uses ESX.RegisterCommand). |
Bridge.CreateCallback | (name, handler) | Registers a server callback (QB uses lib.callback.register, ESX uses ESX.RegisterServerCallback). |
Bridge.OnPlayerLoaded | (handler) | Registers a handler for player load events. |
EditTable.Events
These are the primary integration points. The MDT core calls these functions whenever it needs to perform an action that depends on your serverβs specific setup.EditTable.Events.RemoveMoney
Called when the MDT needs to deduct money from a player (fines, taxes, purchases).
| Parameter | Type | Description |
|---|---|---|
source | number | Server ID of the player. |
type | string | Account type: 'cash' or 'bank'. |
amount | number | Amount to deduct. |
boolean β true if successful.
EditTable.Events.HasItem
Called to check if a player possesses a specific item.
| Parameter | Type | Description |
|---|---|---|
source | number | Server ID of the player. |
item | string | Item name (e.g. 'id_card'). |
count | number? | Minimum quantity required (defaults to 1). |
boolean
EditTable.Events.Query
Every database query in the MDT passes through this function. Override it to use a different SQL library or add query logging.
| Parameter | Type | Description |
|---|---|---|
query | string | Raw SQL query string. |
params | table | Parameterized values. |
table β Query result rows, or {} on error.
[!WARNING]
If you arenβt using oxmysql, you must override this function. The entire MDT depends on it for all database operations.
EditTable.Events.SendDispatch
Controls how dispatch alerts are routed to players.
| Parameter | Type | Description |
|---|---|---|
data.code | string | 10-code (e.g. '10-31'). |
data.title | string | Alert headline. |
data.description | string | Detailed description. |
data.location | string | Street / area name. |
data.jobs | table | Array of job names to target. |
data.coords | table? | {x, y, z} coordinates. |
data.sound | string? | Sound effect name. |
data.blip | table? | Blip configuration {sprite, scale, color, name}. |
[!TIP] Add your webhook logic or external CAD forwarding inside this function after the player loop.
EditTable.Functions (Server)
| Function | Signature | Description |
|---|---|---|
GetPlayer | (source) β player | Returns the framework player object. |
GetJob | (source) β job | Returns the playerβs current job table. |
IsOnDuty | (source) β boolean | Checks if the player is on duty. |
GetCitizenId | (source) β string | Returns the playerβs unique identifier. |
ReportError | (code, message) | Logs a formatted error to console and optionally to Discord. |
SendDebug | (category, title, message, debugType, fields?) | Sends a debug log to console and Discord webhook (only when Config.Debug = true). |
EditTable.Functions.ErrorCodes (Server)
| Code | Constant | Meaning |
|---|---|---|
#ERR-00001 | DATABASE_ERROR | SQL query failed. |
#ERR-00002 | PLAYER_NOT_FOUND | Player object could not be resolved. |
#ERR-00003 | INSUFFICIENT_FUNDS | Not enough money for the operation. |
#ERR-00004 | INVALID_JOB | Job name doesnβt match any configured job. |
#ERR-00005 | ITEM_NOT_FOUND | Inventory item not found. |
#ERR-00006 | PERMISSION_DENIED | Grade/rank insufficient for the action. |
#ERR-99999 | UNKNOWN_ERROR | Fallback for uncategorized errors. |
π Server β LSPD Module (editable/server/lspd.lua)
All police-specific logic: player actions, database queries, and generator functions.
EditTable.LSPD.Functions
GenerateSSN()
Generates a unique Social Security Number for citizens (6-digit numeric by default).
GenerateVIN()
Generates a unique Vehicle Identification Number (12-character alphanumeric).
GenerateWeaponSerial()
Generates a weapon serial number using Config.WeaponSerialization settings.
HandleSentence()
Called when a full sentence (fine + jail) is applied. Handles both online and offline players.
EditTable.LSPD.Events
| Function | Parameters | Description |
|---|---|---|
JailPlayer | (source, targetSource, citizenId, time) | Sends a player to jail. Handles online and offline scenarios. |
FinePlayer | (source, targetSource, citizenId, amount, reason) | Deducts a fine from the playerβs bank and deposits into the police society. |
GrantLicense | (source, targetSource, citizenId, type) | Grants a license via MDT DB and framework metadata. |
RevokeLicense | (source, targetSource, citizenId, type) | Removes a license from MDT DB and framework metadata. |
TransferVehicle | (source, plate, targetCitizenId) | Transfers vehicle ownership in the database. |
EditTable.LSPD.Queries
| Function | Parameters | Returns | Description |
|---|---|---|---|
SearchCitizen | (query) | table[] | Searches players by name or citizen ID. Returns processed list with wanted flag. |
GetCitizenDetails | (citizenId) | table|nil | Fetches full charinfo, job, metadata for a citizen. |
SearchVehicle | (query) | table[] | Searches vehicles by plate or model name. |
GetVehicleDetails | (plate) | table|nil | Returns full vehicle record for a plate. |
UpdateOfficerStats | (citizenId, type, amount) | void | Increments an officerβs statistic counter via UpdateStatistic export. |
GetWarrants | (citizenId?) | table[] | Returns active warrants (all, or filtered by citizen). Includes firstName/lastName from JOIN. |
IssueWarrant | (citizenId, reason, author) | number | Inserts a new warrant into lspd_warrants and returns the ID. |
DeleteWarrant | (id) | void | Removes a warrant by ID from lspd_warrants. |
IsCitizenWanted | (citizenId) | boolean | Returns true if the citizen has any active warrants. |
[!NOTE] All queries are framework-aware. The default implementation uses different SQL depending onConfig.Framework('qb'/'qbox'usesplayers,'esx'usesusers). Override the specific query function if your schema differs.
π Server β EMS Module (editable/server/ems.lua)
Medical-specific events and queries for the ambulance/EMS interface.
EditTable.EMS.Events
| Function | Parameters | Description |
|---|---|---|
BillPatient | (source, targetSource, citizenId, amount, reason) | Bills a patient. Online: deducts from bank, adds to ambulance society. Offline: creates phone invoice. |
RevivePlayer | (source, targetSource) | Triggers a revive on the target player. |
[!WARNING]EMS_HandleTreatment(used by theApplyTreatmentexport) currently contains hardcoded QB-Core calls (QBCore.Functions.GetPlayerByCitizenId,qb-banking). If you use ESX or a different banking resource, override this function ineditable/server/ems.lua:
EditTable.EMS.Queries
| Function | Parameters | Returns | Description |
|---|---|---|---|
SearchPatient | (query) | table[] | Searches patients by name, SSN, or citizen ID. |
GetPatientDetails | (citizenId) | table|nil | Returns charinfo for a specific patient. |
UpdateOfficerStats | (citizenId, type, amount) | void | Increments an EMS workerβs statistic counter. |
βοΈ Server β DOJ Module (editable/server/doj.lua)
Court system logic β case management, citizen/vehicle lookups, and incident management.
EditTable.DOJ.Queries
Case Management
| Function | Parameters | Returns | Description |
|---|---|---|---|
GetPendingCasesCount | () | number | Returns the total count of incidents in the database. |
GetCases | () | table[] | Fetches all incidents with suspects, vehicles, officers, and notes. |
SearchCases | (query) | table[] | Searches incidents by title or ID. |
CreateCase | (data, author) | number | Creates a new incident with suspects, vehicles, and officers. Returns the ID. |
UpdateCaseStatus | (id, status) | boolean | Updates the status of an incident (e.g. 'OPEN', 'CLOSED'). |
UpdateCaseDescription | (id, description) | boolean | Updates the description text of an incident. |
AddIncidentItem | (incidentId, type, item) | boolean | Adds a suspect, vehicle, or officer to an incident. |
RemoveIncidentItem | (incidentId, type, itemId) | boolean | Removes a suspect, vehicle, or officer from an incident. |
AddCaseNote | (incidentId, note) | boolean | Appends a note to the incidentβs notes JSON. |
Citizen & Vehicle Lookups
| Function | Parameters | Returns | Description |
|---|---|---|---|
SearchCitizen | (query) | table[] | Enhanced citizen search with mugshot and wanted status. |
SearchVehicle | (query) | table[] | Vehicle search with wanted/stolen tags from lspd_vehicle_tags. |
GetVehicleDetails | (plate) | table|nil | Full vehicle details including notes and image. |
AddVehicleNote | (plate, note, author) | boolean | Appends a note to the vehicleβs tag record. |
DeleteVehicleNote | (plate, noteId) | boolean | Deletes a specific note from a vehicle. |
SetVehicleWanted | (plate, wanted) | boolean | Flags or unflags a vehicle as wanted. |
Citizen Actions
| Function | Parameters | Returns | Description |
|---|---|---|---|
AddCitizenNote | (citizenid, title, content, author) | number | Adds a note to a citizenβs record. |
SetCitizenWanted | (citizenid, reason, author) | number | Issues a warrant for the citizen. |
AddSentence | (citizenid, fine, jail, offense, author) | number | Records a conviction in lspd_convictions. |
GrantLicense | (citizenid, type, author) | number | Grants a license via the DOJ path. |
Employee Management
| Function | Parameters | Returns | Description |
|---|---|---|---|
GetEmployees | () | table[] | Fetches all DOJ employees with duty status, callsign, avatar, and activity info. |
π’ Server β Business Module (editable/server/business.lua)
Business panel logic β employee management, banking queries, and HR operations.
EditTable.Business.Events
| Function | Parameters | Description |
|---|---|---|
HireEmployee | (source, businessName, targetSource) | Hook called when someone is hired (stub β add your logic). |
FireEmployee | (source, businessName, citizenId) | Hook called when someone is fired (stub β add your logic). |
EditTable.Business.Queries
Employee Operations
| Function | Parameters | Returns | Description |
|---|---|---|---|
GetEmployees | (jobName) | table[] | Fetches all employees for a given job from the database. |
HireEmployee | (citizenId, jobName, grade) | boolean | Sets a citizenβs job in the database (primarily for offline hiring). |
FireEmployee | (citizenId) | boolean | Sets a citizenβs job to 'unemployed'. |
GetPlayerJob | (citizenId) | table|nil | Returns the offline job data for validation. |
PromoteEmployee | (citizenId, jobName, newGrade) | boolean | Updates the grade level of an employee. |
UpdateBadge | (citizenId, newBadge) | boolean | Changes the callsign/badge stored in player metadata. |
SuspendEmployee | (citizenId) | boolean | Toggles the is_suspended metadata flag. Also sets job.onduty = false when suspended. |
AddNote | (citizenId, newNote) | boolean | Prepends a note to the employeeβs business_notes metadata. |
DeleteNote | (citizenId, noteId) | boolean | Removes a note by ID from business_notes. |
GetBusinessBalance | (jobName) | number | Gets the business bank balance via Bridge.Bank.GetBalance() or direct DB query (ESX). |
Finance & Banking
| Function | Parameters | Returns | Description |
|---|---|---|---|
GetRevenue | (jobName, days, offsetDays?) | number | Total deposit sum from bank_statements for the period. offsetDays shifts the window back. |
GetExpenses | (jobName, days) | number | Total withdrawal sum from bank_statements for the period. |
GetWeeklyRevenue | (jobName) | table[] | Daily revenue breakdown for the last 7 days (for charts). Fields: date_day, total, day_name. |
GetRecentTransactions | (jobName, limit?) | table[] | Last N transactions from bank_statements. Default limit: 5. |
[!NOTE] Finance queries depend on thebank_statementstable. If your banking resource uses a different table or schema, override these functions ineditable/server/business.lua.
[!WARNING]Business_HandleBonus(used by theGiveBonusexport) currently contains hardcoded QB-Core calls. If you use ESX or a different framework, override this function:
π Client β Core Module (editable/client/main.lua)
The client-side bridge controls animations, UI initialization, dispatch routing, and targeting zones.
EditTable.ClientEvents
| Function | Description |
|---|---|
OpenTablet() | Plays the tablet pull-out animation when the MDT opens. |
CloseTablet() | Stops the animation when the MDT closes. |
[!TIP] Want a different animation? Change the anim dict and clip name. Want no animation at all? Leave the function body empty.
EditTable.Functions (Client)
| Function | Signature | Description |
|---|---|---|
GetPlayerData | () β table | Returns the current playerβs data via the framework bridge. |
GetJob | () β table|nil | Returns the current playerβs job table. |
IsOnDuty | () β boolean | Checks if the current player is on duty. |
ReportError | (code, message) | Logs a client-side error with file/line info to console. |
| Code | Constant | Meaning |
|---|---|---|
#ERR-10001 | UI_ERROR | NUI/UI rendering issue. |
#ERR-10002 | CALLBACK_TIMEOUT | Server callback exceeded 10-second timeout. |
#ERR-10003 | ANIMATION_ERROR | Animation dict failed to load. |
#ERR-10004 | INVALID_PLAYER_DATA | Player data is missing or malformed. |
#ERR-99999 | UNKNOWN_ERROR | Fallback for uncategorized errors. |
Bridge Functions (Client)
| Function | Signature | Description |
|---|---|---|
Bridge.GetPlayerData | () β table | Returns the current playerβs full data (job, metadata, items). |
Bridge.Notify | (text, type?, length?) | Shows a notification (defaults: type='info', length=5000ms). |
Bridge.TriggerCallback | (name, cb, ...) | Triggers a server callback with a 10-second timeout guard. |
Bridge.IsPlayerLoaded | () β boolean | Returns true if the player is fully loaded (login check). |
Bridge.GetClosestVehicle | (coords) β entity | Returns the closest vehicle entity. |
Bridge.GetClosestPlayer | () β id, distance | Returns the closest playerβs ID and distance. |
Bridge.OpenMenu | (data) | Opens a context menu (uses ox_lib context or qb-menu). |
Bridge.AddBoxZone | (data) | Creates an interaction zone (auto-detects ox_target, qbx_target, qb-target). |
Bridge.AddGlobalPlayer | (options) | Adds global player targeting options. |
Bridge.RemoveZone | (name) | Removes a targeting zone by name. |
π Client β LSPD Module (editable/client/lspd.lua)
Police-specific client commands and keybinds.
Registered Commands
| Command | Keybind | Description |
|---|---|---|
/bk1 | β | Sends a Code 2 backup alert. |
/bk2 or /bk | β | Sends a Code 3 backup alert. |
/bk3 | β | Sends a Code 3 critical backup alert. |
/10-13 | β | Triggers an βOfficer Downβ alert to all emergency services. |
/mdt_dispatch | β | Toggles the dispatch overlay panel. |
/panic_button | CTRL + L | Sends a panic button alert (10-second cooldown). |
π Quick Start: Customizing EditTable
Example 1 β Custom fine system with Discord logging
Example 2 β Custom jail integration
Example 3 β Custom database driver
Example 4 β Using the Global Logging System
Example 5 β Custom tablet animation
Example 6 β Custom Dispatch Handler (Forward to External CAD)
Β© XR-Core Systems | Professional FiveM Resources
