Thread Tools Display Modes
01-18-17, 11:29 AM   #1
natinusala
A Murloc Raider
Join Date: Jul 2016
Posts: 8
When does GetChannelList becomes available ?

Hello,

I'm trying to use the GetChannelList method on the PLAYER_LOGIN event ; when logging in, the values it returns are all nil. When reloading tho, it works fine, which lets me think that the channels are loaded after the login.

So here is my question : which even should I use instead of PLAYER_LOGIN ? It should fire when logging in, or after a loading.

Thanks !
  Reply With Quote
01-18-17, 05:21 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
You can try iterating through ChatFrame1.channelList (ChatFrame2.channelList, etc) instead. I have some personal code involving some channels and that list is usable at PLAYER_LOGIN. The pairs in that table are the same returns as GetChannelList, with the index being the channel number.
  Reply With Quote
01-22-17, 08:46 AM   #3
natinusala
A Murloc Raider
Join Date: Jul 2016
Posts: 8
The code works but not as intended ; the function returns the list of all channels in the chat frames, not all channels the player is currently in. For instance, it says that I'm in the trade channel while being outside of a city.
  Reply With Quote
01-23-17, 03:56 AM   #4
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by natinusala View Post
which even should I use instead of PLAYER_LOGIN ?
You could try CHANNEL_UI_UPDATE, but it e.g. only fires when you leave/join channels
https://github.com/Gethe/wow-ui-sour....lua#L725-L726

From my own testing that information is not yet available after any of the loading process events. Do you really need that information at loadup? Blizzard only uses it in reponse to that event, and when the user is going into the chat options
https://github.com/Gethe/wow-ui-sour...ua#L1935-L1941

Last edited by Ketho : 01-23-17 at 04:02 AM.
  Reply With Quote
01-23-17, 04:07 AM   #5
natinusala
A Murloc Raider
Join Date: Jul 2016
Posts: 8
I need to have an event which fires when the player enters the trade channel and is able to send messages into it, including logging in and out and reloading the UI (because when logged out you can't send messages). I already registered the channel notify event to see when you enter and leave a city, but I need a way to fire that event when the user joined the channel when logging in.
  Reply With Quote
01-23-17, 06:49 PM   #6
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 309
I tested this for a few mins on a few different characters with leaving/entering cities with both trade chat enabled/disabled as well as on login/reload with no issues.


Code:
local function CanUseTrade()

   local i

   for i = 1, 10 do	-- i have no clue how many channels you're allowed to be in at once so i just put 10
      local _, cName = GetChannelName(i)
      if cName and cName:match("Trade") then
         return true
      end
   end

   return nil

end

local CLF = CreateFrame("Frame")
CLF:RegisterEvent("PLAYER_ENTERING_WORLD")	-- fires when player is entering world from login/reload
CLF:RegisterEvent("ZONE_CHANGED")		-- fires on zone change - there's 2 other zone change events but they're not really needed
CLF:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE")	-- fires when you join/leave channels
CLF:SetScript("OnEvent", function(self, event, ...)

   if CanUseTrade() then
      print("You can use trade chat!")
   else
      print("You cannot use trade chat!")
   end

end)

Last edited by Tim : 01-26-17 at 01:25 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » When does GetChannelList becomes available ?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off