xxxxxxxxxx
{{wowapi}} __NOTOC__
Set the active voice channel by providing an ID.
<!-- List return values and arguments as well as function name, follow Blizzard usage convention for args -->
successful = SetActiveVoiceChannelBySessionID(id)
== Arguments ==
<!-- List each argument, together with its type -->
:;id : Number - Channel id.
== Returns ==
<!-- List each return value, together with its type -->
:;success: Boolean - returns true/1 if channel was changed successfully.
== Triggers Events ==
<!-- If this function triggers an event, name it here. If not, remove the entire section. -->
:* "[[Events/V#VOICE_SESSIONS_UPDATE|VOICE_SESSIONS_UPDATE]]", fired if the function fires successfully and the active channel is switched.
== Example ==
<!-- If it helps, include an example here, though it's not required if the usage is self-explanatory -->
local success = SetActiveVoiceChannelBySessionID(2)
<big>'''Result'''</big>
<!-- If it helps, include example results here, though they are not required. You're allowed to cheat liberally since WoW isn't a command line language. -->
success = 1
== Details ==
<!-- Details not appropriate for the main description can go here.
REMOVE the section if you're just going to restate the intro line! -->
:Note: This function cannot place you in the channels under the 'World' category (e.g. Trade, LookingForGroup).
:Id is assigned when the client joins a channel, not by the order of the channels in the Voice Chat window. This means generic channels such as 'Party' and 'Battleground' will not have a static id if you join any number of custom channels before joining a party or battleground. If you wish to find the id of a channel use the [[API GetNumVoiceSessions|GetNumVoiceSessions]] and [[API GetVoiceSessionInfo|GetVoiceSessionInfo]] functions as shown below.
function GetChannelIDByName(name)
for id=1, GetNumVoiceSessions() do
if name == GetVoiceSessionInfo(id) then
return id
end
If you don't need to keep a reference of the id and simply wish to set a channel as active by name.
function SetChannelIDByName(name)
SetActiveVoiceChannelBySessionID(id)
break