SetPlayerVoiceChannel: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Server|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 ch..."
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Info|Function|Server|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)}}
Line 26: Line 26:
{{RelatedFunctions}}
{{RelatedFunctions}}
* [[IsPlayerVoiceChannel]]
* [[IsPlayerVoiceChannel]]
* [[SetPlayerVoiceChannel]]
*[[SetPlayerVoiceRange]]

Latest revision as of 17:12, 11 January 2021

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