Mmarks = {} |
Mmarks[UnitName("player")] = {} |
|
local f = CreateFrame("frame") |
f:RegisterEvent("CHAT_MSG_ADDON") |
f:RegisterEvent("UPDATE_BATTLEFIELD_STATUS") |
f:RegisterEvent("PARTY_MEMBERS_CHANGED") |
f:SetScript("OnEvent", function(self, event, ...) |
if self[event] then return self[event](self, event, ...) end |
end) |
|
local function InvaBroad(prefix,text) |
if GetNumPartyMembers() > 0 then SendAddonMessage(prefix,text,"PARTY") |
elseif GetNumRaidMembers() > 5 then SendAddonMessage(prefix,text,"RAID") |
end |
end |
|
function f:CHAT_MSG_ADDON(self,prefix,message,channel,name) |
if (channel == "PARTY" or channel == "RAID") and prefix == "InvaRequest" and not name == UnitName("player") then |
local AV = GetItemCount(20560) |
local WSG = GetItemCount(20558) |
local AB = GetItemCount(20559) |
local EotS = GetItemCount(29024) |
local SotA = GetItemCount(42425) |
local output = AV.."@"..WSG.."@"..AB.."@"..EotS.."@"..SotA |
InvaBroad("InvaBroadcast",output) |
elseif (channel == "PARTY" or channel == "RAID") and prefix == "InvaBroadcast" and not name == UnitName("player") then |
local AV,WSG,AB,EotS,SotA = string.split("@",message) |
if not Mmarks[name] then Mmarks[name] = {} end |
table.wipe(Mmarks[name]) |
table.insert(Mmarks[name],1,AV) |
table.insert(Mmarks[name],2,WSG) |
table.insert(Mmarks[name],3,AB) |
table.insert(Mmarks[name],4,EotS) |
table.insert(Mmarks[name],5,SotA) |
end |
end |
|
function f:UPDATE_BATTLEFIELD_STATUS() |
InvaBroad("InvaRequest") |
end |
|
function f:PARTY_MEMBERS_CHANGED() |
for k,v in pairs(Mmarks) do |
if not UnitInParty(k) then Mmarks[k] = nil end |
end |
end |
|
function CalculateMarks() |
local AV,WSG,AB,EotS,SotA = 0,0,0,0,0 |
for k,v in pairs(Mmarks) do |
AV = AV + v[1] |
WSG = WSG + v[2] |
AB = AB + v[3] |
EotS = EotS + v[4] |
SotA = SotA + v[5] |
end |
return AV,WSG,AB,EotS,SotA |
end |
|
local bgtable |
hooksecurefunc("PVPBattleground_UpdateBattlegrounds", function() |
if not Mmarks[UnitName("player")] then Mmarks[UnitName("player")] = {} end |
table.wipe(Mmarks[UnitName("player")]) |
table.insert(Mmarks[UnitName("player")],1,GetItemCount(20560)) |
table.insert(Mmarks[UnitName("player")],2,GetItemCount(20558)) |
table.insert(Mmarks[UnitName("player")],3,GetItemCount(20559)) |
table.insert(Mmarks[UnitName("player")],4,GetItemCount(29024)) |
table.insert(Mmarks[UnitName("player")],5,GetItemCount(42425)) |
|
local AV,WSG,AB,EotS,SotA = CalculateMarks() |
local BGtext1,BGtext2,BGtext3,BGtext4,BGtext5 |
if GetNumPartyMembers() > 1 then |
BGtext1 = "("..GetItemCount(20560).."/"..AV..") " |
BGtext2 = "("..GetItemCount(20558).."/"..WSG..") " |
BGtext3 = "("..GetItemCount(20559).."/"..AB..") " |
BGtext4 = "("..GetItemCount(29024).."/"..EotS..") " |
BGtext5 = "("..GetItemCount(42425).."/"..SotA..") " |
else |
BGtext1 = "("..GetItemCount(20560)..") " |
BGtext2 = "("..GetItemCount(20558)..") " |
BGtext3 = "("..GetItemCount(20559)..") " |
BGtext4 = "("..GetItemCount(29024)..") " |
BGtext5 = "("..GetItemCount(42425)..") " |
table.wipe(bgtable) |
bgtable = { |
["Alterac Valley"] = GetItemCount(20560), |
["Warsong Gulch"] = GetItemCount(20558), |
["Arathi Basin"] = GetItemCount(20559), |
["Eye of the Storm"] = GetItemCount(29024), |
["Strand of the Ancients"] = GetItemCount(42425), |
["Isle of Conquest"] = GetItemCount(47395), |
} |
for k,v in pairs(bgtable) do |
for i=1,5 do |
if _G["BattlegroundType"..i]:GetText() == k then |
_G["BattlegroundType"..i]:SetText("("..v..") ".._G["BattlegroundType"..i]:GetText()) |
end |
end |
end |
BattlegroundType1:SetText(BGtext1..BattlegroundType1:GetText()) |
BattlegroundType2:SetText(BGtext2..BattlegroundType2:GetText()) |
BattlegroundType3:SetText(BGtext3..BattlegroundType3:GetText()) |
BattlegroundType4:SetText(BGtext4..BattlegroundType4:GetText()) |
BattlegroundType5:SetText(BGtext5..BattlegroundType5:GetText()) |
end) |
|
PVPMicroButton:RegisterForClicks("RightButtonUp"); |