Skip to content

Player-side API

local radio = exports.meridian:getState()
if radio and radio.connected and radio.talkgroup then
print(("On %s (%d) in zone %s"):format(radio.talkgroup.name, radio.talkgroup.id, radio.zone.name))
end

getState() returns nil until the radio has finished loading (a second or two after joining). After that it always returns the latest state:

Field Meaning
power Switched on
connected Switched on and connected to the radio system
connection "offline", "connecting", "online" or "error"
visible The radio UI is showing
unitId, alias This radio’s unit ID and alias (for example 1-ADAM-12 Smith)
systemName The radio system’s name
zones Every zone the radio may use: { id, name, alias, talkgroups = { { id, name, alias }, ... } }
zone The selected zone { id, name, alias }, or nil
talkgroup The selected talkgroup { id, name, alias }, or nil
transmitting The player is transmitting (the system granted the call)
receiving The call heard right now: { talkgroupId, unitId, alias, emergency }, or nil
emergency This radio has an emergency active
emergencies Every active emergency: { unitId, alias, talkgroupId, acknowledgedBy } (acknowledgedBy is nil until a dispatcher acknowledges it)
priority IDs of the talkgroups in this radio’s codeplug that have priority traffic
patched IDs of the talkgroups in this radio’s codeplug that dispatch patched to others
inhibited A dispatcher or administrator has disabled this radio
signal { bars = 0-4, siteId }
volume 0–150 (percent)
model "handheld" or "mobile"
speaker Calls play on the speaker, so players nearby hear them; false means an earpiece
announcements The radio speaks the zone and channel name when switched: the community allows it and the player hasn’t turned it off
battery { percent = 0-100, charging, low } for the handheld, or nil when batteries are off. low is true at 20% or less

These are local client events: they fire only on the player’s own machine, and never reach the server.

Event Arguments
meridian:stateChanged state, previousState (previousState is nil the first time). Fires last, after any of the events below
meridian:powerChanged on
meridian:connectionChanged connected
meridian:talkgroupChanged talkgroup, zone (either can be nil)
meridian:transmitStart talkgroup
meridian:transmitStop none
meridian:receiveStart { talkgroupId, unitId, alias, emergency }
meridian:receiveStop none
meridian:emergencyChanged active (this radio’s own emergency)
meridian:emergenciesChanged the full emergencies list
meridian:priorityChanged the full priority list
meridian:patchedChanged the full patched list
meridian:signalChanged bars, siteId
meridian:visibilityChanged visible
meridian:speakerChanged on (speaker true, earpiece false)
meridian:batteryChanged the new battery (fires at most once per whole percent)

When the player moves from one call to the next without a gap, receiveStop is followed immediately by receiveStart.

AddEventHandler("meridian:transmitStart", function(talkgroup)
-- your own radio animation, a HUD "TX" light, etc.
end)
AddEventHandler("meridian:emergenciesChanged", function(emergencies)
for _, e in ipairs(emergencies) do
print(("EMERGENCY: %s on talkgroup %d%s"):format(e.alias, e.talkgroupId,
e.acknowledgedBy and (" (acknowledged by " .. e.acknowledgedBy .. ")") or ""))
end
end)

In JavaScript: on("meridian:talkgroupChanged", (talkgroup, zone) => { ... }) and exports.meridian.getState().

Export Effect
setPower(on) Switch the radio on or off
setVisible(visible) Show the whole radio UI, or hide it (ends peek)
setTalkgroup(id, zoneId?) Select a talkgroup. Without zoneId it stays in the current zone if the talkgroup is there, otherwise it uses the first zone that has it. Returns false if the radio is off or can’t use that talkgroup
setZone(zoneId) Select a zone (and its first talkgroup). Returns false if the radio is off or doesn’t have that zone
setVolume(percent) 0–150
setEmergency(active) Raise or clear this radio’s emergency (raised on the selected talkgroup). Returns false if the radio is off or not connected
setPtt(down) Press (true) or release (false) push-to-talk. Always release what you press
setHeadless(on) Hide the built-in radio UI for good, so your own HUD can replace it. The radio keeps working
setBuiltinAnimation(on) Turn the built-in transmit animation on or off, so you can play your own
setSpeaker(on) Speaker (true, players nearby hear calls) or earpiece (false). Saved on the player’s machine. While the player wears earpiece clothing the change isn’t saved, and with the speaker locked, true is refused
setAnnouncements(on) Turns the player’s voice announcements on or off, like /radiovoice. Saved on the player’s machine. Has no effect while the community has them off
useItem(item?, slot?) Show, peek or hide the radio, like the show/peek/hide key (for inventory item scripts). Pass the item’s slot ({ slot = 3 }, as ox_inventory does) so the radio in that slot is the one in use
hasItem() Whether the player carries the radio item (always true when the server doesn’t require one)
setName(name) Name the radio the player holds, like /radioname; nil or "" clears it. The player sees whether it worked
openNamePrompt() Open the text box for naming the radio
setBattery(percent) Set the handheld’s charge (0–100). Returns false when batteries are off
useBattery() Put a spare battery in, for the spare battery item in ox_inventory. Returns false if spares are off or the battery is already full
setRadioMouse(on) Give the player the mouse to click the radio’s buttons (true), or take it back (false), like /radiomouse
openSettings() / closeSettings() Open or close the radio settings screen, like /radiosettings (for a phone app or a settings menu)
openTablet() / closeTablet() Open or close the in-game dispatch tablet, like /dispatch
isTabletOpen() Whether the dispatch tablet is open
useTablet() Open or close the tablet, for the tablet item in ox_inventory. With meridian_tablet_item set, opening needs the item
setSirenAudible(vehicle, on) For siren resources: whether vehicle’s siren is sounding (true/false), or nil to let the game decide, so it’s heard behind transmissions. Call it on the driver’s client. See Sirens from siren resources

With a radio item required (meridian_item), setPower(true), setVisible(true) and useItem() do nothing for a player without the item, and the player sees “You don’t have a radio.”

The radio enforces its normal rules: a player can only select talkgroups their radio is programmed with, an inhibited radio stays silent, and so on. setTalkgroup returning true means the request was accepted; watch talkgroupChanged for the result.

-- A panic button in your own script
RegisterCommand("panic", function()
if not exports.meridian:setEmergency(true) then
print("Your radio is off or has no signal")
end
end)
-- Jump to the mutual aid talkgroup
exports.meridian:setTalkgroup(501)

These are replicated convars (setr) so each player’s game can read them. None is secret.

setr meridian_headless "true" # hide the built-in radio UI for everyone (a HUD resource replaces it)
setr meridian_animation "false" # turn off the built-in transmit animation for everyone
setr meridian_animation_weapons "pistols" # only pistols stay aimed while transmitting ("all" by default, or "none")
setr meridian_animation_dict "my@anims" # play your own transmit animation, streamed by your resource...
setr meridian_animation_name "talk_radio" # ...with this clip (left arm only, unless weapons is "none")
setr meridian_hud "false" # no small radio HUD while the radio is hidden (your own HUD shows it)
setr meridian_proximity "false" # nearby players no longer hear the talker through proximity voice
setr meridian_speaker "false" # radios are never heard by players nearby
setr meridian_speaker_range "12" # how far a radio on speaker carries, in metres (2-20, default 8)
setr meridian_ambient "false" # no background noise (sirens, engines, gunfire) behind transmissions
setr meridian_ambient_level "50" # background noise level, 0-100 (default 100)
setr meridian_siren_audio "statebag" # only the meridianSiren state bag says which sirens are sounding (default "game")
setr meridian_streamdeck "false" # players can't use the Meridian Stream Deck plugin

See Voice, speakers and background noise for what the speaker and background noise settings do, and Stream Deck for the plugin.

A resource can also turn the built-in radio UI or animation off for one player at runtime with setHeadless or setBuiltinAnimation.