Radios and calls
Channels with spatial: false deliver voice to their members regardless of
distance or dimension. Playback has no world position, and range has no effect.
The speaker’s ped can be outside the listener’s streaming range.
For voice service configuration, see Your first voice channel.
Radio membership
Section titled “Radio membership”Create a channel for each radio group. This example adds and removes players, then sends the channel ID to their client for a radio interface:
// @ts-check/// <reference types="@revomp/types-server" />import * as revo from 'revo-server';
const radio = new revo.VoiceChannel({ spatial: false });
/** @param {revo.Player} player */function joinRadio(player) { if (!radio.addPlayer(player, { listen: true, transmit: true })) return false;
revo.emitClient(player, 'radio:joined', radio.id); return true;}
/** @param {revo.Player} player */function leaveRadio(player) { if (radio.removePlayer(player)) { revo.emitClient(player, 'radio:left', radio.id); }}Check access to the radio group on the server before adding a player. A frequency or group name in your interface maps to a channel chosen by the server. Each channel has its own membership, so players can listen to several groups.
radio.id on the server matches networkId in the client’s voice.channels.
The radio:joined and radio:left events are example script events. Membership
updates arrive through the voice connection separately, so the joined event can
arrive before the channel appears in voice.channels.
Removing a member stops their transmission and reception on that channel. Disconnected players are removed automatically. Destroy the channel when the radio group itself is removed.
Choose where to transmit
Section titled “Choose where to transmit”Automatic selection includes every channel with transmit permission, up to 16. A player who joins a radio with transmit permission can therefore speak on both the radio and proximity channels. Use explicit selection when the interface offers separate radio, phone and proximity modes.
| Client call | Result |
|---|---|
voice.setTransmitChannels([channelId]) |
Select one channel. |
voice.setTransmitChannels([proximityId, radioId]) |
Select both channels. |
voice.setTransmitChannels([]) |
Stop outgoing voice on all channels. |
voice.setTransmitChannels(null) |
Restore automatic selection. |
Each successful call replaces the entire selection. Listening permissions stay
unchanged. A selection can contain up to 16 distinct channel IDs. Unknown IDs
return false and leave the previous selection in place. Invalid or duplicate
IDs, or more than 16 entries, throw an error.
This example selects one available channel or returns to permitted spatial channels. It assumes spatial channels are used for proximity voice:
// @ts-check/// <reference types="@revomp/types-client" />import * as revo from 'revo-client';
/** @param {number} channelId */function selectVoiceChannel(channelId) { const channel = revo.voice.channels.find((entry) => entry.networkId === channelId); if (!channel?.transmit) return false;
return revo.voice.setTransmitChannels([channelId]);}
function selectProximityChannels() { const ids = revo.voice.channels .filter((channel) => channel.spatial && channel.transmit) .map((channel) => channel.networkId);
return revo.voice.setTransmitChannels(ids);}selectVoiceChannel() returns false while the channel is unavailable or lacks
transmit permission. Wait for its entry in voice.channels before enabling the
interface action. If a radio control selects the channel while held, restore
the proximity selection on release and on loss of window focus. See
Keyboard, mouse and game controls.
Establish an explicit selection before granting radio transmit permission if the radio should stay silent until selected. Recompute the selection when the player changes channels or speaking mode. After a full reconnect, selection returns to automatic. Stopping the resource that last set the selection also restores automatic behavior. Keep selection decisions together when several features share voice.
Selecting a channel leaves microphone activation under the player’s voice settings. With push-to-talk enabled, the configured talk action must still be held. Server transmit permission is required in every mode.
Phone calls
Section titled “Phone calls”Use one non-spatial channel per accepted call. This example creates a channel for two connected players and removes it if either cannot be added:
// @ts-check/// <reference types="@revomp/types-server" />import * as revo from 'revo-server';
/** * @param {revo.Player} caller * @param {revo.Player} recipient */function startCall(caller, recipient) { if (caller === recipient) return null;
const call = new revo.VoiceChannel({ spatial: false }); if (!call.addPlayer(caller) || !call.addPlayer(recipient)) { call.destroy(); return null; }
return call;}Create the channel after the server accepts the call, then send its id to both
participants for client selection. While the phone is ringing, keep participants
out of the call channel. Non-spatial voice can work before a player spawns, so
membership should follow your authentication and call state.
Keep the returned channel with the call state. On hangup or either participant’s
disconnect, destroy it with call.destroy() and restore each remaining client’s
desired transmit selection. Automatic disconnect cleanup removes the player
from the channel but leaves the channel and its other members in place.
For a conference call, add the other accepted participants to the same channel. Each member with transmit permission can speak to the listeners.
Concurrent channels and distant speakers
Section titled “Concurrent channels and distant speakers”The same microphone audio is sent to every selected channel that permits transmission. If a nearby listener receives a speaker through both proximity and radio, each channel is played separately with its own settings. Choose the transmit set according to whether both should be audible.
Radio and phone playback continue when a speaker streams out.
voice.talkingPlayers contains streamed-in players. For a distant participant,
use voice.isPlayerTalking(playerId) and voice.getPlayerLevel(playerId) with
the player’s server ID, supplied through your radio or call state. Supply names
and other interface data through that state as well.