View Single Post
03-31-17, 04:47 PM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
Those timers won't work that way. If 20 people get an achievement, 20 messages will still go out but 10 seconds later.

Try this:

Code:
local autograts=CreateFrame('frame')
autograts:RegisterEvent('CHAT_MSG_GUILD_ACHIEVEMENT')
autograts:SetScript('OnEvent',function()
    autograts.trigger=true
    C_Timer.After(5,function()
        if autograts.trigger then
            autograts.trigger=false
            SendChatMessage('oh wow grats','GUILD')
        end
    end)
end)
This code will wait 5 seconds after the first event, then send only one message for any events that happened in that 5 seconds. This isn't perfect, there could be times where an event happens immediately after the message, causing any timers that were triggered earlier to push out a second message, but this way, you don't spam guild chat with 20 instant messages.

Last edited by Kanegasi : 03-31-17 at 04:50 PM.
  Reply With Quote