Radio
The client-side Radio global manages primary and secondary radio channels and transmit state. It fires EventBus events that VOIP resources (like pma-voice or mumble-voip) can react to without being directly coupled to shiva-core.
Joining a Channel
lua
Radio.join(channel, slot)lua
Radio.join(1, 'primary') -- join channel 1 on primary slot
Radio.join(5, 'secondary') -- join channel 5 on secondary slot| Parameter | Type | Default | Description |
|---|---|---|---|
channel | integer | required | Channel number (1–255) |
slot | string | 'primary' | 'primary' or 'secondary' |
Leaving a Channel
lua
Radio.leave(slot) -- leave the given slot (default: 'primary')
Radio.leaveAll() -- leave both primary and secondaryIf the player is currently transmitting on the slot being left, transmission is stopped automatically.
Transmitting
lua
Radio.transmitStart(slot) -- begin transmitting on slot (default: 'primary')
Radio.transmitStop() -- stop transmittinglua
-- Tie transmit to a keybind
Keybinds.register('mymodule:radioTalk', 'Radio Transmit', 'CAPS',
function() Radio.transmitStart('primary') end,
function() Radio.transmitStop() end
)Reading State
lua
Radio.getChannel(slot) -- integer|nil — channel number for the slot
Radio.isTransmitting() -- boolean — currently transmitting?Events
Radio emits EventBus events. Your VOIP integration resource listens to these to switch channels and key up the mic:
| Event | Payload | When |
|---|---|---|
radio:joined | { channel, slot } | Player joins a channel |
radio:left | { channel, slot } | Player leaves a channel |
radio:transmitStart | { channel, slot } | Player keys up |
radio:transmitStop | { channel, slot } | Player keys down |
lua
-- In your VOIP integration module
EventBus.on('radio:transmitStart', function(data)
-- data.channel, data.slot
exports['pma-voice']:setRadioChannel(data.channel)
exports['pma-voice']:radioTalkingStart()
end)
EventBus.on('radio:transmitStop', function()
exports['pma-voice']:radioTalkingStop()
end)Full Example — Job Radio on Duty
lua
-- When a player goes on duty for a job
AddEventHandler('mymodule:onDuty', function(jobChannel)
Radio.join(jobChannel, 'primary')
Keybinds.register('mymodule:radioTalk', 'Job Radio', 'CAPS',
function() Radio.transmitStart('primary') end,
function() Radio.transmitStop() end
)
end)
-- When the player goes off duty
AddEventHandler('mymodule:offDuty', function()
Radio.leaveAll()
Keybinds.unregister('mymodule:radioTalk')
end)API Reference
| Method | Description |
|---|---|
Radio.join(channel, slot?) | Join a channel on the given slot |
Radio.leave(slot?) | Leave the channel on the given slot |
Radio.leaveAll() | Leave both primary and secondary channels |
Radio.transmitStart(slot?) | Begin transmitting on the given slot |
Radio.transmitStop() | Stop transmitting |
Radio.getChannel(slot?) | Returns the channel number for the slot, or nil |
Radio.isTransmitting() | Returns true if currently transmitting |
Client-only
Radio is a client-side global. It is not available in server scripts.