Skip to main content

πŸ–§ API β€” Server Side

Nearly all backend routing integrations occur exclusively inside the editable/server/ folder without exposing core escrowed code. This page covers server exports, secure event triggers, and admin commands. For the full EditTable reference, see the dedicated EditTable Reference.

πŸ“€ Server Exports

All exports are registered in editable/server/ files and available to any external script via exports['xr-mdt']:ExportName(...).

Logging

ExportParametersDescription
AddLog(source, job, action_type, details, debugType?)Records an audit log to mdt_logs DB table and forwards to Discord webhook.
exports['xr-mdt']:AddLog(
    source,
    "police",
    "Report: Created",
    "Officer created report #105 for citizen John Doe",
    "General" -- Webhook category from Config.Webhooks.Types
)
AddLog Parameter Details:
ParameterTypeRequiredDescription
sourcenumberβœ…Server ID of the player performing the action.
jobstringβœ…Job/faction name (e.g. 'police', 'ambulance'). Used for webhook routing.
action_typestringβœ…The action title (e.g. 'Fine Issued', 'Warrant Created').
detailsstringβœ…Full descriptive details of the action.
debugTypestring❌Webhook category key (e.g. 'Money', 'Items', 'Database').

Weapons

ExportParametersReturnsDescription
GenerateWeaponSerial()stringGenerates a unique serial number based on Config.WeaponSerialization.
GenerateVin()stringGenerates a unique VIN (verified against DB for uniqueness).
local serial = exports['xr-mdt']:GenerateWeaponSerial()
-- e.g. "SN-A1B2-C3D4"

local vin = exports['xr-mdt']:GenerateVin()
-- e.g. "A3BF92KL1MNP"

Vehicles

ExportParametersReturnsDescription
AddVehicle(source, targetId, model, garage, financeData?, ownerOverride?)boolean, plate, vinAdds a vehicle to the database with auto-generated plate and VIN.
local success, plate, vin = exports['xr-mdt']:AddVehicle(source, targetPlayerId, 'adder', 'pillboxgarage', nil, nil)
if success then
    print("Vehicle added. Plate: " .. plate .. " | VIN: " .. vin)
end
Finance Data Structure (for financed vehicles):
local financeData = {
    balance       = 50000,  -- Remaining balance
    paymentamount = 5000,   -- Monthly payment amount
    paymentsleft  = 10,     -- Number of payments remaining
    financetime   = 30      -- Total finance term in days
}
ownerOverride can be:
  • A citizenid string β€” assigns to that citizen.
  • 'police' β€” generates a LSPD XXX plate.
  • 'ambulance' β€” generates an EMS XXXX plate.

Sentences & Medical

ExportParametersReturnsDescription
AddSentence(citizenId, fine, jailTime, reason, authorName?)voidRecords a conviction in lspd_convictions and applies effects (fine + jail).
ApplyTreatment(citizenId, amount, treatmentName)voidBills a patient and applies treatment costs.
GiveBonus(citizenId, amount, businessName)voidGives a monetary bonus to an employee.
-- Issue a conviction from an external script
exports['xr-mdt']:AddSentence('QJB123', 5000, 36, 'Armed Robbery', 'Officer Smith')

-- Bill a patient
exports['xr-mdt']:ApplyTreatment('QJB456', 2500, 'Surgery')

-- Give an employee bonus
exports['xr-mdt']:GiveBonus('QJB789', 1000, 'police')
[!WARNING] AddSentence broadcasts TriggerClientEvent('xr-mdt:client:citizenUpdated', -1, citizenId) after recording. This refreshes the profile on all open MDT instances.

Device Toggles

These exports bypass item checks and directly trigger device actions:
ExportParametersDescription
tablet(source)Opens the MDT tablet for the specified player.
bodycam(source)Triggers bodycam toggle (respects item check).
gps(source)Triggers GPS toggle (respects item check).
tracking_band(source)Triggers tracking band toggle (respects item check).
document(source, item)Opens a document viewer for the player.
toggleBodycam(source)Force-toggles bodycam (bypasses item check).
toggleGPS(source)Force-toggles GPS (bypasses item check).
-- Force-open tablet for a player
exports['xr-mdt']:tablet(source)

-- Force-toggle bodycam without item requirement
exports['xr-mdt']:toggleBodycam(source)

Database Auditor

ExportParametersReturnsDescription
getDatabaseAuditor()XRAuditor tableReturns the database auditor object for validation.
local auditor = exports['xr-mdt']:getDatabaseAuditor()
local results = auditor.ValidateDatabase()
print("Found: " .. results.found .. "/" .. results.total)
for _, tbl in ipairs(results.missing) do
    print("MISSING: " .. tbl)
end

⚑ Server Events (NetEvents)

xr-mdt:server:triggerDispatch

Force a dispatch notification to all on-duty players in specified jobs. Can be triggered from a client via TriggerServerEvent or from another server script.
ParameterTypeDescription
data.codestring10-code identifier (e.g. '10-99').
data.titlestringHeadline for the dispatch panel.
data.descriptionstringDetailed context.
data.locationstringStreet / area label.
data.jobstableJob names that receive the ping.
data.coordstable?{x, y, z} coordinates for blip.
data.bliptable?Blip config {sprite, scale, color, name}.
data.soundstring?Sound effect name.
-- From a client script
TriggerServerEvent('xr-mdt:server:triggerDispatch', {
    code        = '10-99',
    title       = 'Bank Robbery',
    description = 'Armed hostiles hitting the vault.',
    location    = 'Legion Square',
    jobs        = {'police', 'ambulance'}
})

-- From a server script (no source required)
TriggerEvent('xr-mdt:server:triggerDispatch', {
    code  = '10-31',
    title = 'Store Robbery',
    jobs  = {'police'}
})
[!TIP] The dispatch is routed through EditTable.Events.SendDispatch(data) in editable/server/main.lua. Override that function to add custom behavior (e.g., forward to external CAD, Discord webhook).

xr-mdt:server:triggerNotification

Send a NUI notification directly to a player from any script:
ParameterTypeDescription
textstringNotification text.
typestring'success', 'error', or 'info'.
lengthnumberDuration in milliseconds.
TriggerNetEvent('xr-mdt:server:triggerNotification', "License granted.", 'success', 5000)

xr-mdt:server:requestOpenMDT

Sent by the client when the player presses the MDT keybind or command. Internally validates the player’s job and triggers xr-mdt:client:open:
-- Triggered automatically by the client β€” do not call directly.
-- To open the tablet from server, use the export instead:
exports['xr-mdt']:tablet(source)

πŸ”§ Admin Commands (Server)

These commands are registered via Bridge.RegisterCommand() and respect framework-specific permission systems.
CommandArgsPermissionDescription
/givevehicleid model garage?AdminAdds a vehicle to the target player’s database record.
/testvinβ€”AdminGenerates and prints a test VIN.
/setbodycamidAdminForce-toggles bodycam for a player (bypasses item check).
/setgpsidAdminToggles GPS for a player.

βš–οΈ Conviction System (LSPD)

The sentencing system applies fines and jail simultaneously. Override the logic in editable/server/lspd.lua:
-- editable/server/lspd.lua
EditTable.LSPD.Functions.HandleSentence = function(source, citizenId, fine, jailTime, reason, authorName)
    -- 1. Deduct fine from player's bank (online or offline)
    -- 2. Add fine to police society account
    -- 3. Send player to jail (online) or write to jail_sentences (offline)
    return true
end

-- Backward-compatible global alias
function LSPD_HandleSentence(...)
    return EditTable.LSPD.Functions.HandleSentence(...)
end
[!IMPORTANT] For the complete editable API including all EditTable.Events, EditTable.Functions, EditTable.Queries, and per-module breakdowns, see the EditTable Reference β†’