# createVoiceChannel (Server)

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

- **Platform**: MY Multiplayer (MYMP)
- **Kind**: Lua Function
- **Side**: Server
- **Category**: Voice
- **URL**: https://wiki.mymp.gg/en/createVoiceChannel

## Syntax

```lua
element|false createVoiceChannel(int mode, float maxDistance)
```

## Parameters

| Name | Type | Description |
| --- | --- | --- |
| `mode` | `int` | `0`: 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. |
| `maxDistance` | `float` | Range 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

```lua
local proximity = createVoiceChannel(1, 30)

addEventHandler("onPlayerJoin", root, function()
    addPlayerToVoiceChannel(proximity, source)
end)
```

### Coming from MTA

MTA has no voice channels. The modes follow FiveM's, without mode `2`.

### Note

A player who is in no channel is heard by nobody.

## See also

- [addPlayerToVoiceChannel (Server)](https://wiki.mymp.gg/en/addPlayerToVoiceChannel.md): Puts a player in a voice channel. From then on they hear and are heard by the others in the channel.
- [deleteVoiceChannel (Server)](https://wiki.mymp.gg/en/deleteVoiceChannel.md): Destroys a voice channel. The players who were in it stop hearing each other through it.
- [setPlayerMutedInVoiceChannel (Server)](https://wiki.mymp.gg/en/setPlayerMutedInVoiceChannel.md): Mutes a player in a voice channel: they still hear the channel, but nobody hears them through it.
