ktoxktox docs

Customization

Framework hooks and localization for ktx_dispatch.

Customization

ktx_dispatch ships with ESX support out of the box. Adapt it to any framework by editing the files in custom/.

Server Hooks

custom/server.lua contains three exports.

getPlayerName

Returns the character name for display in dispatch calls.

function getPlayerName(source)
    local xPlayer = ESX.GetPlayerFromId(source)
    if not xPlayer then return "Unknown" end
    return xPlayer.getName()
end

For QBx/QB-Core, use Player.PlayerData.charinfo.firstname and lastname.

getPlayerJobType

Returns the service key from EmergencyServices that matches the player's framework job. The default implementation iterates EmergencyServices and returns the first enabled service whose job field matches the player's framework job, or nil otherwise.

function getPlayerJobType(source)
    local xPlayer = ESX.GetPlayerFromId(source)
    if not xPlayer then return nil end
    return xPlayer.getJob().name
end

The returned value must match a key in EmergencyServices (e.g. "police", "ambulance"), not the raw framework job name. If the player is not an emergency worker, return nil.

hasDispatchAccess

Checks if the player has an emergency job and can view the dispatch panel.

function hasDispatchAccess(source)
    local jobType = getPlayerJobType(source)
    return jobType ~= nil
end

Return true to grant access, false to deny. Citizens can still create calls but cannot view the full dispatch panel.

Client Hooks

custom/client.lua exports notify, which is also bound to the ktx_dispatch:notify net event so the server can fire notifications without an extra export call.

function notify(message, type, title, duration)
    ESX.ShowNotification(message, type, duration, title)
end
  • message - notification text
  • type - "success", "error", "info", or any framework-supported string
  • title - optional title above the message
  • duration - display time in milliseconds

Localization

Translation files live in locales/. The resource ships with en.json and de.json.

To add a new language:

  1. Copy locales/en.json to locales/{code}.json (e.g. fr.json)
  2. Translate all string values
  3. Set "language": "fr" in the Framework section of static/config.json

Keys must stay the same. Only translate the values.