View Single Post
03-25-21, 07:47 AM   #2
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
This works for me fine on Retail (I didn't bother writing code to join a specific chat channel and get the index from that)

I also didn't test it with another player or account, just with myself
Lua Code:
  1. local prefix = "SomePrefix123"
  2. local playerName = UnitName("player")
  3.  
  4. local function OnEvent(self, event, ...)
  5.     if event == "CHAT_MSG_ADDON" then
  6.         print(event, ...)
  7.     elseif event == "PLAYER_ENTERING_WORLD" then
  8.         local isInitialLogin, isReloadingUi = ...
  9.         if isInitialLogin or isReloadingUi then
  10.             C_ChatInfo.RegisterAddonMessagePrefix(prefix)
  11.             C_ChatInfo.SendAddonMessage(prefix, "Hello world!", "CHANNEL", 5)
  12.         end
  13.     end
  14. end
  15.  
  16. local f = CreateFrame("Frame")
  17. f:RegisterEvent("CHAT_MSG_ADDON")
  18. f:RegisterEvent("PLAYER_ENTERING_WORLD")
  19. f:SetScript("OnEvent", OnEvent)
  Reply With Quote