Skip to content

Proximity voice

For the initial setup, see Your first voice channel. A spatial channel can keep all participating players as members. The server selects nearby listeners as they move, so scripts can leave membership unchanged when players enter or leave speaking range.

range is the maximum delivery distance in metres, measured in 3D between the speaker’s and listener’s player positions. Height differences count. Players exactly at the configured distance are eligible to receive voice.

Both players need a spawned position and membership in the enabled channel. The speaker needs transmit permission and the listener needs listen permission. Player movement and channel changes reach the voice service asynchronously, so crossing the range boundary can take a short time to affect delivery.

range belongs to the channel. Setting channel.range = 10 changes the limit for every speaker using that channel. It accepts finite values greater than zero.

GTA handles positional playback and distance attenuation. Increasing range allows more distant recipients without changing that attenuation curve. Actual audibility also depends on microphone level, channel gain and the listener’s volume settings. Adjust channel.volume separately, in decibels from -100 to 0, where 0 leaves the channel gain unchanged.

Spatial delivery requires equal player dimensions. Use separate dimensions or channel membership to isolate private rooms and instances. The server’s distance check uses player coordinates and dimensions, with no wall or interior-geometry test.

Voice remains active when a player is hidden with player.streamed = false. If a speaker’s ped is unavailable on a listener’s client, spatial playback uses the position included with the voice data. To silence a hidden player, revoke their transmit permission or remove their channel membership.

A scripted camera leaves the player’s server position unchanged. The server continues selecting voice recipients around that player position.

Use separate spatial channels when players need different speaking distances. Each player listens to all three and has transmit permission on one. This example uses 5, 20 and 40 metres as project-defined presets:

Server
// @ts-check
/// <reference types="@revomp/types-server" />
import * as revo from 'revo-server';
const channels = new Map([
['whisper', new revo.VoiceChannel({ spatial: true, range: 5 })],
['normal', new revo.VoiceChannel({ spatial: true, range: 20 })],
['shout', new revo.VoiceChannel({ spatial: true, range: 40 })],
]);
/** @param {revo.Player} player */
export function joinVoice(player) {
for (const [mode, channel] of channels) {
channel.addPlayer(player, { listen: true, transmit: mode === 'normal' });
}
}
/**
* Call after checking the player's permission to speak.
* @param {revo.Player} player
* @param {string} mode
*/
export function setSpeakingMode(player, mode) {
const selected = channels.get(mode);
if (!selected || !selected.hasPlayer(player)) return false;
for (const channel of channels.values()) {
const permissions = channel.getPlayerPermissions(player);
if (permissions) {
channel.setPlayerPermissions(player, {
listen: permissions.listen,
transmit: channel === selected,
});
}
}
return true;
}
/** @param {revo.Player} player */
export function leaveVoice(player) {
for (const channel of channels.values()) channel.removePlayer(player);
}
export function stopVoice() {
for (const channel of channels.values()) channel.destroy();
}

In this example, joinVoice(player) adds the player to all three channels with normal speaking mode enabled. setSpeakingMode(player, mode) switches transmit permission to 'whisper', 'normal' or 'shout'. It returns false for unknown modes or players outside the selected channel.

Automatic client channel selection follows the server’s transmit permissions. If your client script selects channels explicitly, update that selection to include the chosen mode. Keep only one proximity mode transmitting at a time, since overlapping voice channels have separate playback paths.

Apply your server mute policy before calling setSpeakingMode(), because the function grants transmit permission on the selected channel. Existing listen permissions are preserved. Use leaveVoice(player) for a character logout and stopVoice() when disposing of this channel group. Disconnect cleanup is automatic.

With two players in the same dimension, select whisper and move the listener about ten metres away. Switch the speaker to normal without moving either player. Then change one player’s dimension and confirm that proximity voice stops.

Repeat with the speaker above or below the listener to check the vertical distance. Compare several positions inside each range to tune audibility, including microphone and output volumes, before choosing the final presets.