SetPlayerVoiceChannel: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
Line 1: Line 1:
{{Info|Function|Server|1.1.0}}
{{Info|Function|Server|1.1.0}}


{{FuncDescription|Changes the voice channels for a player. Players in the same channel will hear each other. Channel 0 is the default 3D world channel where players are added automatically on join. Other channels have their sound in 2D.}}
{{FuncDescription|Adds or removes a player from a voice channel. Players in the same channel will hear each other. Channel 0 is the default 3D world channel where players are added automatically on join. Other channels have their sound in 2D.}}


{{FuncSyntax|SetPlayerVoiceChannel(player, channel, enable)}}
{{FuncSyntax|SetPlayerVoiceChannel(player, channel, enable)}}

Revision as of 22:04, 28 April 2020

SetPlayerVoiceChannel

Type: Function
Context: Server
Introduced: v1.1.0

Description

Adds or removes a player from a voice channel. Players in the same channel will hear each other. Channel 0 is the default 3D world channel where players are added automatically on join. Other channels have their sound in 2D.

Syntax

SetPlayerVoiceChannel(player, channel, enable)

Parameters

  • player
    The player identifier.
  • channel
    The channel id as an integer. There is no limit on channels.
  • enable
    true to add a player to the voice channel. false to remove them.

Return Value

  • This function returns true on success. If a player is already in a channel it will return false.

Example

function cmd_vc(player, channel)
    -- Remove the player from the world channel. Nearby players will no longer hear him.
    SetPlayerVoiceChannel(player, 0, false)

    -- Add the player to their desired voice channel.
    SetPlayerVoiceChannel(player, channel, true)
end
AddCommand("vc", cmd_vc)

See also