Integration and exports
Patrolink integration on FiveM: qbx_radio compatibility, client and server exports, events, hooks for dispatch, callsigns and logs, and Eleven Police MDT setup.
qbx_radio compatibility
Patrolink's fxmanifest.lua includes:
provide 'qbx_radio'
With it, FiveM treats eleven_radio as if it were qbx_radio. The scripts you already run (police tablets, EMS scripts…) keep calling exports.qbx_radio:* and listening to qbx_radio:client:*, and Patrolink answers. Nothing to change.
- Don't run qbx_radio and Patrolink at the same time.
- If you want to keep qbx_radio for some reason, delete the
provide 'qbx_radio'line. Then call the exports asexports.eleven_radio:*.
Client exports
They work as exports.qbx_radio:<name> and as exports.eleven_radio:<name>.
| Export | Returns | What it does |
|---|---|---|
IsRadioOn() | boolean | Whether the radio is on. |
getCurrentChannel() | number | Current frequency. 0 if off, no channel or no access. |
SetChannel(freq) | boolean | Tunes freq (1 to maxFrequency). Turns the radio on if it was off. Returns false if the player carries no radio, has no access to the channel or the frequency is invalid. |
LeaveChannel() | true | Leaves the current channel. |
powerOff() | — | Turns the radio off. |
reapplyRadio() | — | Re-applies the channel in pma-voice (handy if another script changed it). |
GetRadio() | table | Patrolink only: { modelo, on, freq, unidad }. modelo is 'pl3' or 'pl7'; unidad is { label, codigo } or nil. |
Example, from a tablet that puts the officer on their channel:
if not exports.qbx_radio:SetChannel(3) then
lib.notify({ description = 'You cannot join that channel', type = 'error' })
end
Client events
Each event is fired under two names: the qbx_radio one and Patrolink's own (eleven_radio:client:channelChanged, eleven_radio:client:powerChanged). Listen to whichever you prefer.
| Event | Arguments | When |
|---|---|---|
qbx_radio:client:channelChanged | freq (0 = no channel) | Every time the channel changes, including when powering on. |
qbx_radio:client:powerChanged | on (boolean) | On power on or off. |
AddEventHandler('qbx_radio:client:channelChanged', function(freq)
print('Radio channel:', freq)
end)
Server exports
A player's radio
local radio = exports.eleven_radio:GetPlayerRadio(source)
-- { on = true, model = 'pl3' | 'pl7', frequency = 90, serial = 'PL3-48213' } or nil
Returns the radio the player has switched on, checked against their inventory. nil if none is on.
Locks
Only available with the security module enabled (Config.Security.enabled = true).
| Export | Returns | What it does |
|---|---|---|
LockRadio(serial, reason?, by?) | true, effective or false, error | Locks a radio. effective is the os.time() when it stops working. Errors: 'formato', 'cargando', 'no_existe', 'ya_bloqueada'. |
UnlockRadio(serial, by?) | true or false, error | Removes the lock. Errors: 'formato', 'no_bloqueada'. |
IsRadioLocked(serial) | 'active', 'pending' or false | Lock state (pending = still inside the 90 s margin). |
by can be a player id or a string (for example 'mdt').
local ok, err = exports.eleven_radio:LockRadio('PL7-07155', 'Stolen', source)
With Eleven Police MDT
Patrolink can be the item radio for Eleven Police MDT 4.2 officers. The tablet has its own service radio (unit, department and command), and Patrolink becomes the secondary radio: switching it on switches the tablet radio on, and the dial can be tuned from the tablet's "Secondary" card.
- In the MDT's
config.lua,Config.RadioItemType = 'eleven_radio'. It is the MDT default, so usually you write nothing. The MDT recognizes Patrolink by thenamein itsfxmanifest.lua. - Copy the MDT hooks. The MDT ships
extras/eleven_radio/hooks.lua: copy it over Patrolink'sconfig/hooks.lua(replace the whole file; no hooks to write by hand). It setsKeepRadioEnabled, PANIC from the emergency button, callsigns,/radiolockfor command units and 10-codes in the radio chat. - Match the jobs. Add the MDT's
Config.PoliceJobNamesto Patrolink'sConfig.ServiceJobsandConfig.RestrictedChannels, tolockJobsandlogJobsinconfig/security.lua, and to thePOLICEtable at the top of the copiedhooks.lua. - The items. The MDT's
Config.RadioItemNames(defaultradioandradio_pl7) must match Patrolink'sConfig.Models. - Recommended: the pma-voice multi-channel layer. It is not inside the MDT: it is a separate download, the
eleven-police-extras-gplpackage (folderpma-voice-multicanal, MIT license). With it the dial and the tablet radio are heard at the same time. Stock pma-voice gives each player a single channel: while the tablet radio holds it, the Patrolink screen shows that the service radio is in charge and the dial is only spoken on with the MDT "Secondary" key.
In the server console, the MDT's police-doctor confirms the secundaria, ganchos and multicanal lines. Each hook and the usual problems are covered in Patrolink (eleven_radio), in the MDT documentation.
Note
With Config.RadioItemType = 'eleven_radio', the tablet radio only works while the Patrolink is switched on. That's intended: no radio in hand, no radio.
Hooks (config/hooks.lua)
Patrolink connects to your other scripts from config/hooks.lua, without touching code. Each hook is a function in Config.Hooks. Leave it as nil and the radio uses its built-in behavior.
Client hooks
| Hook | Default | Used for |
|---|---|---|
Config.Hooks.ServicePanic(data) | empty function | Emergency from an on-duty service player. data = { job, control, location, coords }. It runs on the client because most dispatch scripts take the caller from source. |
Config.Hooks.KeepRadioEnabled() | nil (acts as false) | Return true if another script also uses the player's pma-voice radio (job radio, dispatch console…): leaving the dial won't disable radio talk. |
Config.Hooks.IsCuffed() | nil (common state bags and metadata) | Whether the player is cuffed. |
Config.Hooks.IsUnconscious() | nil (common state bags) | Whether they're unconscious or dead. |
Config.Hooks.HandsUp() | nil (handsup state bag) | Whether their hands are up. |
Config.Hooks.Notify(text, kind, title, duration) | nil (ox_lib) | Client notifications. |
Server hooks
| Hook | Default | Used for |
|---|---|---|
Config.Hooks.GetCallsign(source) | nil (no callsigns) | The unit's callsign ('ADAM-10') for the HUD and unit codes. Without it, the unit is the character's name. Must come from a server-trusted source. |
Config.Hooks.IsDispatcher(source) | nil (nobody) | Dispatch operators who may also lock radios. |
Config.Hooks.OnTenCode(source, data) | empty function | A 10-code was sent. data = { unit, grade, name, code, text, job, control, frequency }. |
Config.Hooks.OnCivilianEmergency(source, location, coords) | empty function | Emergency from someone who isn't an on-duty service player. Coordinates come from the server. |
Config.Hooks.Log(action, source, payload) | nil (console when Config.Debug) | Every relevant action (lock, unlock, tencode, emergency, call, decrypt, band_claim, watchdog…). Send it to your log system. |
Config.Hooks.IsBlocked(source) | nil (isCuffed, isDowned, isDead state bags set by the server) | Cuffed or unconscious, for the watchdog. |
Config.Hooks.WatchdogExempt(source, channel) | nil (acts as false) | Return true for players another script puts in the dial range. |
Who's an admin (framework permissions or the command ACE) and who's a job boss (the framework's boss grade) is decided by the radio itself and has no hook.
Example: ps-dispatch
-- config/hooks.lua
Config.Hooks.ServicePanic = function(data)
exports['ps-dispatch']:OfficerDown()
end
Adapt the call to your dispatch: each one has its own export or event.
Example: callsign from metadata
-- config/hooks.lua (server, Qbox example)
Config.Hooks.GetCallsign = function(source)
local player = exports.qbx_core:GetPlayer(source)
local callsign = player and player.PlayerData.metadata.callsign
if callsign and callsign ~= 'NO CALLSIGN' then return callsign end
return nil
end
Use your server's callsign source (MDT, metadata…), never a state bag the client can write.
Your framework's events
The radio listens to Qbox/QBCore events (QBCore:Client:OnPlayerLoaded, OnPlayerUnload, OnJobUpdate, SetDuty) and ESX events (esx:playerLoaded, esx:onPlayerLogout, esx:setJob). If your server uses custom events for job or duty changes, fire TriggerEvent('eleven_radio:jobChanged') on the client from your own script.
If you need an integration the hooks don't cover, open a ticket on our Discord.