M MY Multiplayer: Wiki
Side
Kind

createVoiceChannel

Server

Creates a voice channel. Players only hear each other through the channels they are in.

element|false createVoiceChannel(int mode, float maxDistance)

Parameters

NameTypeDescription
modeint0: everyone in the channel hears each other at full volume. 1: only players within maxDistance metres, in the same dimension and interior, with the volume falling off with distance. 3: like 1, and the channel is destroyed when the last player leaves.
maxDistancefloatRange in metres, above 0 in modes 1 and 3. It is required in mode 0 too, where it is ignored.

Returns

The created voice-channel element, or false if it could not be created.

The channel belongs to the resource that created it. A player in several channels is heard through all of them; if a channel without a distance reaches a listener, they hear the player at full volume.

Example

local proximity = createVoiceChannel(1, 30)

addEventHandler("onPlayerJoin", root, function()
    addPlayerToVoiceChannel(proximity, source)
end)
Coming from MTAMTA has no voice channels. The modes follow FiveM's, without mode 2.
NoteA player who is in no channel is heard by nobody.

See also