View Single Post
03-18-11, 04:42 PM   #3
Akkorian
A Flamescale Wyrmkin
 
Akkorian's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2010
Posts: 111
Hi Rixxon,

This should work:

Lua Code:
  1. local messages = {
  2.     { time = 0, channels = "SAY", message = "Manaflut ! Kuscheln !!" },
  3.     { time = 60, channels = "PARTY", message = "MANATIDE 2MIN CD" },
  4.     { time = 120, channels = "PARTY", message = "MANATIDE 1MIN CD" },
  5.     { time = 150, channels = "PARTY RAID", message = "MANATIDE 30SEK CD" },
  6. }
  7.  
  8. local counter, nextMessage = 0, 1
  9.  
  10. local addon = CreateFrame( "Frame" )
  11. addon:RegisterEvent( "UNIT_SPELLCAST_SUCCEEDED" )
  12. addon:SetScript( "OnEvent", function( self, event, unit, _, _, _, spell )
  13.     if unit == "player" and spell == 16190 then
  14.         -- You cast Mana Tide!
  15.         -- Start running the messages.
  16.         counter, nextMessage = 0, 1
  17.         self:Show()
  18.     end
  19. end )
  20.  
  21. addon:Hide()
  22. addon:SetScript( "OnUpdate", function( self, elapsed )
  23.     -- Add up how much time has passed
  24.     -- since you cast Mana Tide.
  25.     counter = counter + elapsed
  26.  
  27.     local m = messages[ nextMessage ]
  28.     if counter < m.time then
  29.         -- It's not time for a message yet.
  30.         return
  31.     end
  32.  
  33.     -- Send the message!
  34.     for channel in m.channels:gmatch("%S+") do
  35.         SendChatMessage( m.message, channel )
  36.     end
  37.  
  38.     -- Queue up the next message.
  39.     nextMessage = nextMessage + 1
  40.  
  41.     -- Find out if it's done.
  42.     if not messages[ nextMessage ] then
  43.         self:Hide()
  44.         counter, nextMessage = 0, 1
  45.     end
  46. end )

Please post any errors!
__________________
“Be humble, for you are made of earth. Be noble, for you are made of stars.”
  Reply With Quote