View Single Post
04/27/15, 04:01 PM   #15
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,003
Originally Posted by Ayantir View Post
You can't read chat buffer, you need to catch them when messages comes.

Lua Code:
  1. --Put this somewhere above and outside the player activated event callback function
  2. local function myChatMessageChannelCallbackFunction(eventCode, messageType, fromName, text)
  3.    if messageType = CHAT_CHANNEL_GUILD1 then
  4.       d("Guild channel 1 message received from " .. fromName .. ": " .. text)
  5.    end
  6.  
  7.    --return false = run the other event callback functions for the same event
  8.    --return true = don#t run the other event callback functions for this event as you tell them by "true":    Everything was done already in this function here
  9.    --The same applies to ZoPreHook() and ZoPreHookHandler() functions
  10.     return false
  11. end
  12.  
  13. --Put this into player activated event callback function
  14. --Register the event for new text messages to check incoming texts at all the chat channels
  15. EVENT_MANAGER:RegisterForEvent("MyAddonName_ChatMessageChannel", EVENT_CHAT_MESSAGE_CHANNEL, myChatMessageChannelCallbackFunction)
  Reply With Quote