Advertisement
krazyito65

cooldown notification raw code

Jun 26th, 2015
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.34 KB | None | 0 0
  1. Events:CHAT_MSG_CHANNEL
  2.  
  3. --Trigger
  4. function(event, msg, author, _, _, _, _, _, _, channel)
  5.    
  6.    
  7.     --Raid Notification Weak Aura
  8.     --Author: Krazyito - Mal'ganis - US
  9.     --Takes text in specificed channel to alert player someone wants them to use their cooldown.
  10.     --Text syntax: "PlayerName, Spellid"
  11.     --Edit the channel name below and in 'Actions' for custom channel
  12.     --Version 2.0
  13.    
  14.     --Changes:
  15.     --1.1: Got support from ERT.
  16.     --1.2: Some support for single target CDs, the tank that wants it needs to click the spell himself (from ERT) for it to show up with his name. (first version bugged)
  17.     --1.3: Fixed single target section. Now when a single target cooldown is sent by it player, the name of the person who sent the aura will appear.
  18.     --1.3.1: fixed bug where channel name would be case sensetive.
  19.     --2.0: Cleaned A LOT OF CODE. Got rid of the table I had originally made to save the icons I wanted to use. Instead, just use a function to look up the icon. Broke single target fix.
  20.    
  21.    
  22.     if event == "CHAT_MSG_CHANNEL" and string.upper(channel) ==  string.upper("SRCDS") then -- if something is said in this channel -- EDIT THIS CHANNEL NAME
  23.        
  24.        
  25.         local stringTable = aura_env.DoSplit(msg, ", ") --parse the string into a table
  26.         if stringTable[1] == aura_env.playerName then -- if the playername is mentioned
  27.            
  28.             aura_env.sender = string.gsub(author, "%-[^|]+", "") -- store the name of the person who sent the command and remove their realm name.
  29.             aura_env.ouputIcon  =  select (3, GetSpellInfo(tonumber(stringTable[2]))) -- Save the icon information. (3rd parameter of GetSpellInfo
  30.            
  31.             return true
  32.         end
  33.     end
  34.    
  35.     return false
  36. end
  37.  
  38.  
  39.  
  40. --Display
  41. function()
  42.    
  43.     if  aura_env.ouputIcon then  
  44.        
  45.         return  "USE |T" .. aura_env.ouputIcon ..":16|t" -- show icon
  46.     else
  47.         return "Nothing? - report bug"
  48.     end
  49.    
  50. end
  51.  
  52.  
  53. --On Init
  54.  
  55. local split = function (msg, inSplitPattern, outResults ) -- string parser
  56.    
  57.     if not outResults then
  58.         outResults = { }
  59.     end
  60.     local theStart = 1
  61.     local theSplitStart, theSplitEnd = string.find(msg, inSplitPattern, theStart )
  62.     while theSplitStart do
  63.         table.insert( outResults, string.sub(msg, theStart, theSplitStart-1 ) )
  64.         theStart = theSplitEnd + 1
  65.         theSplitStart, theSplitEnd = string.find(msg, inSplitPattern, theStart )
  66.     end
  67.     table.insert( outResults, string.sub(msg, theStart ) )
  68.     return outResults
  69. end
  70.  
  71. aura_env.DoSplit = split -- save the above function as a global to this aura
  72. aura_env.playerName = UnitName("player") -- get the current player name
  73. aura_env.ouputIcon = "init"
  74. aura_env.sender = "init"
  75.  
  76.  
  77. --custom code by ERT author
  78. local function SpecialClick(data)
  79.     local chat,channel={GetChannelList()}
  80.     for i=1,#chat,2 do
  81.         if string.upper(chat[i+1]) == string.upper("SRCDS") then -- EDIT THE CHANNEL NAME
  82.             channel=chat[i]
  83.             break
  84.         end
  85.     end
  86.    
  87.     if not channel then return end
  88.     SendChatMessage(data.name..", "..data.db[1],"CHANNEL",nil,channel)
  89. end
  90.  
  91. if _G.GExRT and _G.GExRT.A.ExCD2 then
  92.     _G.GExRT.A.ExCD2.db.plugin.UpdateRoster=function(line) line.specialClick=SpecialClick end
  93. end
  94. -------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement