Advertisement
Guest User

Untitled

a guest
Mar 19th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. -- SafeQueue by Jordon
  2. local queueTime
  3. local queue = 0
  4. local button2 = StaticPopupDialogs["CONFIRM_BATTLEFIELD_ENTRY"].button2
  5. local remaining = 0
  6.  
  7. local function SafeQueue_Print(msg)
  8.     DEFAULT_CHAT_FRAME:AddMessage("|cff33ff99SafeQueue|r: " .. msg)
  9. end
  10.  
  11. local function SafeQueue_Timer()
  12.     local secs = GetBattlefieldPortExpiration(queue)
  13.     if secs > 0 then
  14.         local p = StaticPopup_Visible("CONFIRM_BATTLEFIELD_ENTRY")
  15.     print(p)
  16.         if p then
  17.             local color
  18.             if remaining ~= secs then
  19.                 remaining = secs
  20.                 if secs > 20 then
  21.                     color = "f20ff20"
  22.                 elseif secs > 10 then
  23.                     color = "fffff00"
  24.                 else
  25.                     color = "fff0000"
  26.                 end
  27.         local str=string.gsub(_G[p .. "Text"]:GetText(), ".+\n", "У вас есть |cf"..color.. SecondsToTime(secs) .. "|r, чтобы вступить в битву\n")
  28.                 _G[p .. "Text"]:SetText(str)
  29.         print(str)
  30.             end
  31.         end
  32.     end
  33. end
  34.  
  35. local function SafeQueue_Update()
  36.     local queued
  37.     for i=1, 11 do
  38.         local status, _, _, _, _, _, registeredMatch = GetBattlefieldStatus(i)
  39.         if registeredMatch == 1 then
  40.             if status == "queued" then
  41.                 queued = true
  42.                 if not queueTime then
  43.           queueTime = GetTime()
  44.         end
  45.             elseif status == "confirm" then
  46.             if queueTime then
  47.                 queueTime = nil          
  48.                 end
  49.         remaining = 0
  50.         queue = i        
  51.             end
  52.             break
  53.         end
  54.     end
  55.     if not queued and queueTime then queueTime = nil end
  56. end
  57.  
  58. frame = CreateFrame("Frame", nil, UIParent)
  59. frame:SetScript("OnEvent", SafeQueue_Update)
  60. frame:SetScript("OnUpdate", SafeQueue_Timer)
  61.  
  62. frame:RegisterEvent("UPDATE_BATTLEFIELD_STATUS")
  63. StaticPopupDialogs["CONFIRM_BATTLEFIELD_ENTRY"].button2 = nil
  64. StaticPopupDialogs["CONFIRM_BATTLEFIELD_ENTRY"].hideOnEscape = false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement