Functions
Every function returns its value on success and nil, errorCode on failure. See How it works.
Wrapper
Section titled “Wrapper”| Function | Returns |
|---|---|
BeamVoice.isReady() |
true when a compatible BeamVoice plugin answered, else false, errorCode (notReady, incompatible, timeout…). |
BeamVoice.isDisabled() |
true only when the BeamVoice plugin answered that it is not compatible with this file. false while BeamVoice is not loaded yet, or is too old to answer (see Compatibility). |
BeamVoice.setTimeout(seconds) |
true. Sets the timeout of every later call of your plugin. invalidArgument unless seconds is a positive finite number. |
BeamVoice.onReady(listener) |
true, or nil, "invalidArgument" when listener is not a function. See Waiting for BeamVoice. |
BeamVoice.on(event, listener) |
true, or nil, "invalidArgument" when event is empty, "ready" (use onReady) or not a string, or listener not a function. See Events. |
BeamVoice.off(event, listener) |
true when the listener was removed, false when it was not registered. BeamVoice.off(event) removes every listener of that event, BeamVoice.off("ready") those of onReady. nil, "invalidArgument" when event is not a string, or listener is given and not a function. |
Status
Section titled “Status”BeamVoice.getStatus()
Section titled “BeamVoice.getStatus()”Returns a table:
| Field | Type | Description |
|---|---|---|
enabled |
boolean | The voice chat is up on this server. |
epoch |
number | Goes up by 1 each time BeamVoice connects to its voice service, 0 before the first connection. Groups and voice sessions of an older epoch are gone. |
apiVersion |
string | API version of the BeamVoice plugin, for example "1.1.0". |
pluginVersion |
string | Installed BeamVoice plugin version. |
playersInVoice |
number | Number of players in the voice chat. |
Works while the voice chat is down (enabled = false).
BeamVoice.getCapabilities()
Section titled “BeamVoice.getCapabilities()”What this server can do with its BeamVoice plan, audio node and config. Returns a table:
| Field | Type | Description |
|---|---|---|
maxPlayers |
number | Maximum players in the voice chat. |
maxGroups |
number | Maximum number of groups at the same time (0: no group chats in this plan). |
audioEffects |
boolean | Audio effects are on. |
radioSfx |
string or nil | Radio sound preset of the server ("talkie", "police", "cb" or "race"), nil when off. |
groupRadio |
boolean | Groups can use their own radio preset (radio option). |
groupOptions |
boolean | Group options (radio, exclusive) are available. |
groupRoles |
boolean | The listener role is available. |
groupBatch |
boolean | addPlayers adds everyone in one request (it still works without, one player at a time). |
voiceAccessListen |
boolean | setVoiceAccess(playerId, "listen") is available. |
presence |
boolean | BeamVoice knows when a player’s voice page is connected (connected fields, audioConnectedChanged). |
speakingState |
boolean | The server owner turned on api.speaking_state (see Privacy). |
voiceKeys |
boolean | The server owner turned on api.voice_keys (see Privacy). |
While the voice chat is down, the values come from the last connection and unknown features are false.
Players
Section titled “Players”BeamVoice.isInVoice(playerId)
Section titled “BeamVoice.isInVoice(playerId)”true when the player is in the voice chat, else false (also for an id with no player on the game server).
Errors: invalidArgument.
BeamVoice.getVoicePlayers()
Section titled “BeamVoice.getVoicePlayers()”Every player in the voice chat, as a list of:
| Field | Type | Description |
|---|---|---|
id |
number | Player id. |
name |
string | Player name. |
connected |
boolean or nil | The player’s voice page is connected. nil when unknown (older audio node). |
access |
string | "full" or "listen". |
groupId |
string or nil | Group of the player. |
role |
string or nil | "speaker" or "listener" in that group, nil without a group. |
Empty while the voice chat is down.
BeamVoice.getPlayerInfo(playerId)
Section titled “BeamVoice.getPlayerInfo(playerId)”Same fields as getVoicePlayers plus inVoice (boolean), for any player on the game server. access can also be "none".
Errors: playerNotFound (no such player on the game server), invalidArgument.
BeamVoice.setVoiceAccess(playerId, access)
Section titled “BeamVoice.setVoiceAccess(playerId, access)”Decides what a player may do in the voice chat. Returns true.
"full": talk and listen (default)."listen": the player hears the others but nobody hears them. Applied at once if they are in the voice chat, else when they join. Needs thevoiceAccessListencapability, elseunsupported(and nothing changes). Set while the voice chat is down, it is stored without that check; if the audio node cannot enforce it at the next join, the player cannot join (they are told “Voice chat is temporarily unavailable for you on this server.”)."none": the player cannot join. If they are in the voice chat, they are removed (playerLeftVoicewith reason"kicked") and told “You are not allowed to use the voice chat on this server.”
The access is kept until the player leaves the game server, also when BeamVoice reconnects. It can be set while the voice chat is down and applies at the next join. Fires voiceAccessChanged when it changes.
The access is stored before BeamVoice tells the audio node. If the player is in the voice chat and that call fails, you get the error but the access stays stored: it applies at their next join, and calling setVoiceAccess again with the same access retries it right away.
Errors: playerNotFound, invalidArgument, unsupported, and when the audio node call fails serviceDown, playerNotInVoice or unknownError.
BeamVoice.getVoiceAccess(playerId)
Section titled “BeamVoice.getVoiceAccess(playerId)”"full", "listen" or "none".
Errors: playerNotFound, invalidArgument.
BeamVoice.promptJoin(playerId)
Section titled “BeamVoice.promptJoin(playerId)”Shows the BeamVoice join dialog to the player (the one they get when they join the server). Returns true once it is sent; the player still has to accept it.
Errors: playerNotFound, alreadyInVoice, accessDenied (voice access "none"), invalidArgument, serviceDown.
Speaking
Section titled “Speaking”These need api.speaking_state = true in the BeamVoice config, else they return featureDisabled (see Privacy). The state is refreshed with every position update BeamVoice sends to its audio node, several times per second.
BeamVoice.isSpeaking(playerId)
Section titled “BeamVoice.isSpeaking(playerId)”true while the player is talking (by proximity or in their group), else false. While the voice chat is down it returns false.
Errors: featureDisabled, invalidArgument.
BeamVoice.getSpeakingPlayers()
Section titled “BeamVoice.getSpeakingPlayers()”Players talking right now, as a list of { id, proximity, group } (booleans: where they are heard). Empty while the voice chat is down.
Errors: featureDisabled.
Group chats
Section titled “Group chats”A player is in one group at most, and must be in the voice chat to join one. Groups are lost when BeamVoice reconnects to its voice service (you get groupChanged(groupId, "deleted") for each of them), so create them in BeamVoice.onReady, it runs again after each reconnection. Group ids are never reused: an old id returns groupNotFound.
Changes return serviceDown while the voice chat is down.
BeamVoice.groupChat.create(name, options)
Section titled “BeamVoice.groupChat.create(name, options)”Creates a group and returns its id. name: 1 to 100 characters. options (optional):
radio: radio sound preset of the group:"talkie","police","cb","race","off"(no radio sounds) or"default"(follow the server setting, the default). The four presets need thegroupRadiocapability.exclusive:trueto make a closed channel: members only hear their group and nobody hears them by proximity. Defaultfalse.
Options other than the defaults need the groupOptions capability, else unsupported.
Errors: invalidArgument, groupCapReached (maxGroups reached), featureNotInPlan (no group chats or no radio presets in the BeamVoice plan), featureDisabled (radio sounds turned off with audio.radio_sfx = "off"), unsupported, serviceDown.
BeamVoice.groupChat.delete(groupId)
Section titled “BeamVoice.groupChat.delete(groupId)”Deletes the group. Its members stay in the voice chat. Returns true.
Errors: groupNotFound, invalidArgument, serviceDown.
BeamVoice.groupChat.rename(groupId, name)
Section titled “BeamVoice.groupChat.rename(groupId, name)”Returns true. Errors: groupNotFound, invalidArgument, unsupported (older audio node), serviceDown.
BeamVoice.groupChat.setOptions(groupId, options)
Section titled “BeamVoice.groupChat.setOptions(groupId, options)”Changes radio and/or exclusive (same values as create, missing fields stay as they are). Returns true.
Errors: groupNotFound, invalidArgument (also when options is missing), featureNotInPlan (no radio presets in the BeamVoice plan), featureDisabled, unsupported, serviceDown.
BeamVoice.groupChat.addPlayer(groupId, playerId, options)
Section titled “BeamVoice.groupChat.addPlayer(groupId, playerId, options)”Puts the player in the group, moving them out of their current group. Returns true. options (optional): role = "speaker" (default for new members) or "listener" (hears the group, cannot talk in it; needs the groupRoles capability). Adding a member again only changes the role when role is given.
Errors: groupNotFound, playerNotFound, playerNotInVoice, invalidArgument, unsupported, serviceDown.
BeamVoice.groupChat.addPlayers(groupId, playerIds, options)
Section titled “BeamVoice.groupChat.addPlayers(groupId, playerIds, options)”Adds a list of players. Returns { added = { playerId, ... }, failed = { { id = playerId, error = errorCode }, ... } }.
Each failed entry has the code addPlayer would give for that player (playerNotFound, playerNotInVoice…).
Errors (for the whole call): groupNotFound, invalidArgument, unsupported, serviceDown.
BeamVoice.groupChat.removePlayer(groupId, playerId)
Section titled “BeamVoice.groupChat.removePlayer(groupId, playerId)”Takes the player out of the group (they stay in the voice chat). Returns true.
Errors: groupNotFound, playerNotFound, playerNotInVoice, invalidArgument (the player is not in that group), serviceDown.
BeamVoice.groupChat.getGroups()
Section titled “BeamVoice.groupChat.getGroups()”Every group, as a list of { id, name, radio, exclusive, memberCount }. radio is nil when the group follows the server setting. Empty while the voice chat is down.
BeamVoice.groupChat.getGroup(groupId)
Section titled “BeamVoice.groupChat.getGroup(groupId)”Returns { id, name, radio, exclusive, members = { { id, name, role }, ... } }.
Errors: groupNotFound (also while the voice chat is down: its groups are gone), invalidArgument.
BeamVoice.groupChat.getMembers(groupId)
Section titled “BeamVoice.groupChat.getMembers(groupId)”Returns the members list of getGroup.
Errors: groupNotFound (also while the voice chat is down: its groups are gone), invalidArgument.

