local aName = "vBrokerEPGP" local aVersion = "r4" local vBrokerEPGP = CreateFrame("Frame", nil, UIParent) local pName = GetUnitName("player") local data = {} local LDB = LibStub("LibDataBroker-1.1") vBrokerEPGP = LDB:NewDataObject("vBrokerEPGP", { type = "data source", icon = "Interface\\PvPRankBadges\\PvPRank15", text = "EPGP", OnClick = function(self, msg) if msg == "LeftButton" then vBrokerEPGP:GetNote() if EPGPFrame then if EPGPFrame:IsShown() then HideUIPanel(EPGPFrame) else ShowUIPanel(EPGPFrame) end else ChatFrame1:AddMessage(aName..": ".. _G["ADDON_DISABLED"]) end end if msg == "RightButton" then -- Start IF Rigth vBrokerEPGP:GetNote() end -- End IF Rigth end, OnEnter = function(self) vBrokerEPGP:GetNote() GameTooltip:SetOwner(self, "ANCHOR_BOTTOM") if (data.ep ~= nil and data.gp ~= nil) then GameTooltip:AddLine("GP: "..data.gp) GameTooltip:AddLine("EP: "..data.ep) GameTooltip:AddLine("PR: "..string.format ("%.4g",data.pr)) else GameTooltip:AddLine("No data from EPGP") end GameTooltip:Show() end, OnLeave = function() GameTooltip:Hide() end, } ) -- function vBrokerEPGP:GetNote() local ep = 0 local gp = 0 for i=1, GetNumGuildMembers(true) do local name, rank, _, level, _, zone, note, offnote, connected, status, class = GetGuildRosterInfo(i) local tmp_name = split (name,"-") if (pName == tmp_name[1]) then ep, gp = string.match(offnote, "^(%d+),(%d+)$") end end if (ep ~= nil and gp ~= nil) then data.ep = ep data.gp = gp data.pr = ep/(gp+1) vBrokerEPGP.text = "PR: "..string.format ("%.4g",data.pr) end end -- split function -- http://lua-users.org/wiki/SplitJoin function split(str, pat) local t = {} -- NOTE: use {n = 0} in Lua-5.0 local fpat = "(.-)" .. pat local last_end = 1 local s, e, cap = str:find(fpat, 1) while s do if s ~= 1 or cap ~= "" then table.insert(t,cap) end last_end = e+1 s, e, cap = str:find(fpat, last_end) end if last_end <= #str then cap = str:sub(last_end) table.insert(t, cap) end return t end