WoW:API GetChannelName: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
m (Move page script moved page API GetChannelName to API GetChannelName without leaving a redirect)
 
(7 intermediate revisions by 7 users not shown)
Line 1: Line 1:
<center>'''GetChannelName''' ''-Documentation by wowpendium.de-''</center>
{{wowapi}}


Retrieves the id and the name from a specific channel.  
Retrieves the id and the name from a specific channel.  
Line 7: Line 7:
----
----
;''Arguments''
;''Arguments''
:(Number id or String id)


:;id : The id of the channel you want to query, either as a number (1) or as a string ("1"). It seems that ("Trade") also works.
:;id : The numeric id of the channel you want to query, or a string containing the name of the channel.


----
----
Line 15: Line 14:


:;id : a number containing the id of the channel, e.g. 2, or 0 if the channel is not found
:;id : a number containing the id of the channel, e.g. 2, or 0 if the channel is not found
:;name : a string containing the name of the channel, e.g. "Trade - Stormwind", or nil if the channel is not found.
:;name : a string containing the name of the channel, e.g. "Trade - Stormwind", or nil if the channel is not found or the id parameter was a name.
----
----
;''Important''
;''Important''


If the channel argument is the channel name (ie "testchan1"), then the returned channel name is a nil value.<br>
If the channel argument is the channel name (ie "testchan1"), then the returned channel name is a nil value.
If the channel argument is the channel number (ie 6 or "6"), then the returned channel name is correct.<br>
If the channel argument is the channel number (ie 6 or "6"), then the returned channel name is correct.
The channel id returns correctly in both cases.<br>
The channel id returns correctly in both cases.
 
It's also worthy to note the strange behaviour of (at least) Trade channels. Login to a city, GetChannelName("Trade - City") will return the channel number it's on. Step outside the city, you'll leave the channel yet making that call again will return the channel number you *were* on. As such, it's not entirely reliable for detecting if you're in a trade enabled zone.
   
   
----
----
Line 28: Line 29:
  myChannel = 1;
  myChannel = 1;
  id, name = GetChannelName(myChannel);
  id, name = GetChannelName(myChannel);
  if (not id == 0 and name ~= nil) then
  if (id > 0 and name ~= nil) then
   SendChatMessage("This is just a test.", "CHANNEL", nil, myChannel);
   SendChatMessage("This is just a test.", "CHANNEL", nil, id);
  end
  end


Line 40: Line 41:


: Retrieves the name from a specific channel.
: Retrieves the name from a specific channel.
 
: Also returns a 3rd value, seems to always be 0 on enUS client, its purpose is unknown.
----
{{Template:WoW API}}
[[Category:API Functions|GetChannelName]]
[[Category:API Channel Functions|GetChannelName]]

Latest revision as of 04:45, 15 August 2023

WoW API < GetChannelName

Retrieves the id and the name from a specific channel.

id, name = GetChannelName(id);

Arguments
id
The numeric id of the channel you want to query, or a string containing the name of the channel.

Returns
id
a number containing the id of the channel, e.g. 2, or 0 if the channel is not found
name
a string containing the name of the channel, e.g. "Trade - Stormwind", or nil if the channel is not found or the id parameter was a name.

Important

If the channel argument is the channel name (ie "testchan1"), then the returned channel name is a nil value. If the channel argument is the channel number (ie 6 or "6"), then the returned channel name is correct. The channel id returns correctly in both cases.

It's also worthy to note the strange behaviour of (at least) Trade channels. Login to a city, GetChannelName("Trade - City") will return the channel number it's on. Step outside the city, you'll leave the channel yet making that call again will return the channel number you *were* on. As such, it's not entirely reliable for detecting if you're in a trade enabled zone.


Example
-- Check if the specific channel exists
myChannel = 1;
id, name = GetChannelName(myChannel);
if (id > 0 and name ~= nil) then
  SendChatMessage("This is just a test.", "CHANNEL", nil, id);
end
Result

Checks if the channel with id stored in myChannel exists and in this case sends the text "This is just a test" to it.


Description
Retrieves the name from a specific channel.
Also returns a 3rd value, seems to always be 0 on enUS client, its purpose is unknown.