Go to Page... |
|
Thread Tools | Display Modes |
|
01-29-12, 12:15 AM | #1 |
a problem that causes disconnect but no errors
what would cause an addon to make you disconnect but not create errors?
Last edited by Grimsin : 01-29-12 at 12:18 AM. |
|
![]() |
01-29-12, 12:52 AM | #2 |
I remember trying to SendChatMessage improper UI escape sequences (especially achievement links) could make you disconnect, but that specific problem seems to have been fixed ever since cata..
|
|
![]() |
01-29-12, 01:39 AM | #3 |
Too much CPU usage can do it, usually caused by OnUpdate events or inefficient loops. I did some testing a while back with inefficient OnUpdate events to see whether I could disconnect myself and/or others. Wasn't too hard to disconnect myself
![]() |
|
![]() |
01-29-12, 03:59 AM | #4 |
Yes, if an addon locks up the client for too long, you will get disconnected.
If you're working with publicly released addons, though, this is probably not the issue, since such a glaringly obvious problem would (hopefully) have been identified before release, or at least very soon after. Is there a specific addon you think is causing you to disconnect, or are you just getting disconnected periodically for no apparent reason? If it's the latter, I'd be more likely to suspect a general problem with your Internet connection than an addon. If it's the former, you'll get more relevant answers if you name the addon. |
|
![]() |
01-29-12, 10:13 AM | #5 |
Well actually, that code i posted about the dashboard in my own addon seems to be causing it. It does not really "lock up" it just disconnects me. If i disable GrimUI it stops...
edit - this is the code... Code:
local addonName, addon = ... _G[addonName] = addon local SIZE = 15 local DURABILITY_MID_RANGE = 50 local FPS_MID_RANGE = 20 local LATENCY_MID_RANGE = 300 local PERFORMANCEBAR_UPDATE_INTERVAL = PERFORMANCEBAR_UPDATE_INTERVAL or 10 local date, floor, max, min, tonumber = date, floor, max, min, tonumber local GetFramerate, GetGameTime, GetNetStats = GetFramerate, GetGameTime, GetNetStats local colors, CLASS = CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS, addon.CLASS -- Main Frame Creation local DashBoardFrame = CreateFrame('frame', nil, UIParent) DashBoardFrame:SetFrameStrata("HIGH") local DBFbg = DashBoardFrame:CreateTexture(nil, "BACKGROUND") DBFbg:SetAllPoints(DashBoardFrame) --[[----------------------------------------------------------------------------- Individual Frames Creation -------------------------------------------------------------------------------]] local function DashFrameCreate(frametype, framename, template, justify, texture) local frame = CreateFrame(frametype, framename, DashBoardFrame, template) frame:EnableMouse(true) frame:SetHeight(SIZE) frame:SetScript('OnLeave', addon.HideTooltip) frame:SetFrameStrata("HIGH") frame.text = frame:CreateFontString(nil, 'OVERLAY', 'GameFontNormalSmall') frame.text:SetFont([[Fonts\FRIZQT__.TTF]], 12, 'NORMAL') if justify ~= nil then frame.text:SetJustifyH(justify) end if texture == true then frame.texture = frame:CreateTexture() end if frametype == 'Button' then frame:RegisterForClicks("AnyUp") end frame.text:SetPoint('RIGHT') frame.text:SetShadowOffset(1, -1) return frame end DashFrameCreate('Frame',"GUI_DashMail", nil, 'RIGHT', true) DashFrameCreate('Button',"GUI_DashQuest", nil, 'RIGHT', true, true) DashFrameCreate('Button',"GUI_DashDurability", nil, 'RIGHT', true) DashFrameCreate('Button',"GUI_DashInventory", 'SecureHandlerClickTemplate', 'RIGHT', true) DashFrameCreate('Button',"GUI_DashMoney", nil, nil, nil) DashFrameCreate('Button',"clock", nil, 'RIGHT', true) DashFrameCreate('Frame',"GUI_DashLatency", nil, 'RIGHT', nil) DashFrameCreate('Frame',"GUI_DashFPS", nil, 'RIGHT', nil) DashFrameCreate('Button',"GUI_DashSocial", 'SecureHandlerClickTemplate', 'RIGHT', true) DashFrameCreate('Button', "GUI_DashGuild", 'SecureHandlerClickTemplate', 'RIGHT', nil) DashFrameCreate('Button',"GUI_DashSpeed", nil, 'RIGHT', true) -- Mail frame -- GUI_DashMail.texture:SetTexture([[Interface\AddOns\]] .. addonName .. [[\Media\MailIcon]]) GUI_DashMail.texture:SetPoint('RIGHT', GUI_DashMail.text, 'LEFT') GUI_DashMail.texture:SetHeight(12) GUI_DashMail.texture:SetWidth(12) GUI_DashMail.text:SetText(" 188") GUI_DashMail:SetWidth(GUI_DashMail.text:GetStringWidth() + GUI_DashMail.texture:GetWidth() - 8) -- Quests -- GUI_DashQuest.texture:SetTexture([[Interface\AddOns\]] .. addonName .. [[\Media\QuestIcon]]) GUI_DashQuest.texture:SetPoint('RIGHT', GUI_DashQuest.text, 'LEFT') GUI_DashQuest.texture:SetTexCoord(0.25, 0.75, 0.25, 0.75) GUI_DashQuest.texture:SetHeight(12) GUI_DashQuest.texture:SetWidth(12) GUI_DashQuest.text:SetText(" 25/25") GUI_DashQuest:SetWidth(GUI_DashQuest.text:GetStringWidth() + GUI_DashQuest.texture:GetWidth()) -- Armor durability -- GUI_DashDurability.texture:SetTexture([[Interface\Icons\Trade_BlackSmithing]]) GUI_DashDurability.texture:SetPoint('RIGHT', GUI_DashDurability.text, 'LEFT') GUI_DashDurability.texture:SetTexCoord(0.07, 0.93, 0.07, 0.93) GUI_DashDurability.texture:SetHeight(12) GUI_DashDurability.texture:SetWidth(12) GUI_DashDurability.text:SetText(" 100%") GUI_DashDurability:SetWidth(GUI_DashDurability.text:GetStringWidth() + GUI_DashDurability.texture:GetWidth()) -- Inventory -- addon.GUI_DashInventory = GUI_DashInventory GUI_DashInventory.texture:SetTexture([[Interface\AddOns\]] .. addonName .. [[\Media\BagIcon]]) GUI_DashInventory.texture:SetPoint('RIGHT', GUI_DashInventory.text, 'LEFT') GUI_DashInventory.texture:SetHeight(SIZE) GUI_DashInventory.texture:SetWidth(SIZE) GUI_DashInventory.text:SetText(" 888/888") GUI_DashInventory:SetWidth(GUI_DashInventory.text:GetStringWidth() + GUI_DashInventory.texture:GetWidth()) -- Money -- GUI_DashMoney:SetWidth(1) GUI_DashMoney.text:SetTextColor(1, 1, 1) GUI_DashMoney.text:SetAllPoints() -- Clock -- clock.text:SetTextColor(1, 1, 1, 1) clock.text:SetText(" 18:88pm") clock:SetWidth(clock.text:GetStringWidth()) clock.texture:SetHeight(SIZE) clock.texture:SetWidth((clock.text:GetStringWidth() - 6)) clock.texture:SetPoint("CENTER", clock, "CENTER", 5, 0) clock.texture:SetTexture("Interface/PlayerFrame/UI-PlayerFrame-Deathknight-Glow.blp") clock.texture:Hide() -- Latency -- GUI_DashLatency.text:SetText(" 888ms") GUI_DashLatency:SetWidth(GUI_DashLatency.text:GetStringWidth()) -- FPS -- GUI_DashFPS.text:SetText(" 188fps") GUI_DashFPS:SetWidth(GUI_DashFPS.text:GetStringWidth()) -- Social/Friends -- GUI_DashSocial.texture:SetTexture("Interface/FriendsFrame/UI-Toast-FriendOnlineIcon.blp") GUI_DashSocial.texture:SetPoint('RIGHT', GUI_DashSocial.text, 'LEFT') GUI_DashSocial.texture:SetHeight(20) GUI_DashSocial.texture:SetWidth(20) GUI_DashSocial.text:SetText("188") GUI_DashSocial:SetWidth(GUI_DashSocial.text:GetStringWidth() + GUI_DashSocial.texture:GetWidth() - 10) -- Guild Frame -- GuildMicroButtonTabard:SetParent(GUI_DashGuild) GuildMicroButtonTabard:SetPoint('RIGHT', GUI_DashGuild.text, 'LEFT') GuildMicroButtonTabard:SetHeight(5) GuildMicroButtonTabard:SetWidth(5) GuildMicroButtonTabard.emblem:SetHeight(9) GuildMicroButtonTabard.emblem:SetWidth(9) GuildMicroButtonTabard.background:SetHeight(26) GuildMicroButtonTabard.background:SetWidth(21) GuildMicroButtonTabard.emblem:SetPoint("CENTER", GuildMicroButtonTabard.background, "CENTER", 0, -4) GUI_DashGuild.texture1 = GUI_DashGuild:CreateTexture() GUI_DashGuild.texture1:SetTexture("Interface/Buttons/UI-MicroButton-Guild-Banner.blp") GUI_DashGuild.texture1:SetPoint('RIGHT', GUI_DashGuild.text, 'LEFT', 0, 4) GUI_DashGuild.texture1:SetHeight(26) GUI_DashGuild.texture1:SetWidth(21) GUI_DashGuild.texture2 = GUI_DashGuild:CreateTexture() GUI_DashGuild.texture2:SetTexture("Interface/GUI_DashGuild/GuildEmblems_01.blp") GUI_DashGuild.texture2:SetPoint('CENTER', GUI_DashGuild.texture1, 'CENTER', 0, -4) GUI_DashGuild.texture2:SetHeight(9) GUI_DashGuild.texture2:SetWidth(9) GUI_DashGuild.text:SetText("188") GUI_DashGuild:SetWidth(GUI_DashGuild.text:GetStringWidth() + GUI_DashGuild.texture1:GetWidth() - 10) -- Speed -- GUI_DashSpeed.texture:SetTexture("Interface/TAXIFRAME/UI-Taxi-Icon-Green.blp") GUI_DashSpeed.texture:SetPoint('LEFT', GUI_DashSpeed, 'LEFT') GUI_DashSpeed.texture:SetTexCoord(0.25, 0.75, 0.25, 0.75) GUI_DashSpeed.texture:SetHeight(10) GUI_DashSpeed.texture:SetWidth(10) GUI_DashSpeed:SetWidth(46) --[[----------------------------------------------------------------------------- OnEnter Functions -------------------------------------------------------------------------------]] -- Universal OnEnter Setup Func -- local function GUI_ToolTipSetup(self) --if self.tooltip then GameTooltip:ClearLines() --else if not addon.settings.dashOnTop or addon.settings.dashOnTop == false then GameTooltip:SetOwner(self, 'ANCHOR_TOP', 0, 1) else GameTooltip:SetOwner(self, 'ANCHOR_BOTTOM', 0, -5) end --end end -- Clock -- local server_hour, server_minute = 0, 0 local function GUI_DashClock_OnEnter(self) GUI_ToolTipSetup(self) GameTooltip:AddDoubleLine("Today's Date", date("%A, %B %d, %Y")) GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine("Local Time", clock.text:GetText()) GameTooltip:AddDoubleLine("Server Time", ("%d:%.02d %sm"):format(server_hour ~= 0 and server_hour or 12, server_minute, server_hour >= 12 and "p" or "a")) GameTooltip:AddLine(" ") GameTooltip:AddLine("|cffeda55fLeft Click|r toggles the Time Manager", 0.2, 1, 0.2) GameTooltip:AddLine("|cffeda55fRight Click|r toggles the Calendar", 0.2, 1, 0.2) if not self.tooltip then GameTooltip:Show() self.tooltip = true end end clock:SetScript('OnEnter', GUI_DashClock_OnEnter) clock:SetScript('OnLeave', addon.HideTooltip) -- Mail frame -- local function GUI_DashMail_OnEnter(self) if not HasNewMail() then return end GUI_ToolTipSetup(self) MinimapMailFrameUpdate() if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashMail:SetScript('OnEnter', GUI_DashMail_OnEnter) GUI_DashMail:SetScript('OnLeave', addon.HideTooltip) -- Durability Frame -- local equipCost = 0; local bagCost = 0; local totalCost = 0; local pEquipDura = { min=0, max=0}; local pBagDura = { min=0, max=0}; local slots = { "HeadSlot", "ShoulderSlot", "ChestSlot", "WaistSlot", "WristSlot", "HandsSlot", "LegsSlot", "FeetSlot", "MainHandSlot", "SecondaryHandSlot", "RangedSlot" } slots[0] = 'AmmoSlot' --local myTip = nil function GUI_DashDurability:GetDurabilityInfo() pEquipDura = { min=0, max=0}; pBagDura = { min=0, max=0}; if not tmpTip then tmpTip = CreateFrame("GameTooltip", "GUITT") end equipCost = 0 for _, slotName in ipairs(slots) do local item = _G["Character" .. slotName] local hasItem, _, repairCost = tmpTip:SetInventoryItem("player", item:GetID()) local Minimum, Maximum = GetInventoryItemDurability(item:GetID()) if hasItem and repairCost and repairCost > 0 then equipCost = equipCost + repairCost end if Minimum and Maximum then pEquipDura.min = pEquipDura.min + Minimum pEquipDura.max = pEquipDura.max + Maximum end end bagCost = 0 for bag = 0, 4 do for slot = 1, GetContainerNumSlots(bag) do local hasCooldown, repairCost = tmpTip:SetBagItem(bag, slot) local Minimum, Maximum = GetContainerItemDurability(bag, slot) if repairCost and repairCost > 0 then bagCost = bagCost + repairCost end if Minimum and Maximum then pBagDura.min = pBagDura.min + Minimum pBagDura.max = pBagDura.max + Maximum end end end if bagCost < 0 then bagCost = 0 end totalCost = equipCost + bagCost end local function GUI_DashDurability_OnEnter(self) --if not myTip then --myTip = CreateFrame('GameTooltip') --myTip:Hide() --end local cP = (pEquipDura.max > 0 and floor(pEquipDura.min / pEquipDura.max * 100)) or 100 local bP = (pBagDura.max > 0 and floor(pBagDura.min / pBagDura.max * 100)) or 100 local tP = ((pEquipDura.max + pBagDura.max) > 0 and floor( (pEquipDura.min + pBagDura.min) / (pEquipDura.max + pBagDura.max) * 100)) or 100 if cP > 100 then cP = 100 end if bP > 100 then bP = 100 end if tP > 100 then tP = 100 end GUI_ToolTipSetup(self) GameTooltip:AddLine(_G['REPAIR_COST']) GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(_G['CURRENTLY_EQUIPPED'].." ("..addon:DurColor(cP)..cP.."%|r".."):", addon:MoneyToString(equipCost, true)) GameTooltip:AddDoubleLine("Inventory".." ("..addon:DurColor(bP)..bP.."%|r".."):", addon:MoneyToString(bagCost, true)) GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine(_G['REPAIR_ALL_ITEMS'].." ("..addon:DurColor(tP)..tP.."%|r".."):", addon:MoneyToString(totalCost, true)) GameTooltip:AddDoubleLine("Friendly Discount", addon:MoneyToString(addon:truncate((totalCost * 0.95), 0), true)) GameTooltip:AddDoubleLine("Honored Discount", addon:MoneyToString(addon:truncate((totalCost * 0.9), 0), true)) GameTooltip:AddDoubleLine("Revered Discount", addon:MoneyToString(addon:truncate((totalCost * 0.85), 0), true)) GameTooltip:AddDoubleLine("Exaulted Discount", addon:MoneyToString(addon:truncate((totalCost * 0.8), 0), true)) GameTooltip:AddLine(" ") GameTooltip:AddLine("|cffeda55fLeft Click|r toggle Auto-Repair " .. (addon.settings.autoRepair and "|cff88ff88on|r" or "|cffff8888off|r"), 0.2, 1, 0.2) GameTooltip:AddLine("|cffeda55fRight Click|r toggle Guild Funds " .. (addon.settings.GuildRepair and "|cff88ff88on|r" or "|cffff8888off|r"), 0.2, 1, 0.2) if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashDurability:SetScript('OnEnter', GUI_DashDurability_OnEnter) GUI_DashDurability:SetScript('OnLeave', addon.HideTooltip) -- Inventory -- local function GUI_DashInventory_OnEnter(self) GUI_ToolTipSetup(self) local keyBinding = GetBindingKey("TOGGLEBACKPACK"); GameTooltip:AddLine(""..NORMAL_FONT_COLOR_CODE.."Backpack ("..keyBinding..")"..FONT_COLOR_CODE_CLOSE); GameTooltip:AddLine(" ") GameTooltip:AddLine(string.format(NUM_FREE_SLOTS, (MainMenuBarBackpackButton.freeSlots or 0))); GameTooltip:AddLine(" ") GameTooltip:AddLine("|cffeda55fLeft Click|r toggle Inventory", 0.2, 1, 0.2) GameTooltip:AddLine("|cffeda55fRight Click|r toggle Bag Bar", 0.2, 1, 0.2) if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashInventory:SetScript('OnEnter', GUI_DashInventory_OnEnter) GUI_DashInventory:SetScript('OnLeave', addon.HideTooltip) -- Quest -- local function GUI_DashQuest_OnEnter(self) if not addon.settings.dashOnTop or addon.settings.dashOnTop == false then GameTooltip:SetOwner(self, 'ANCHOR_TOP', 0, 1) else GameTooltip:SetOwner(self, 'ANCHOR_BOTTOM', 0, -5) end GameTooltip:AddLine(MicroButtonTooltipText(QUESTLOG_BUTTON, "TOGGLEQUESTLOG")); if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashQuest:SetScript('OnEnter', GUI_DashQuest_OnEnter) GUI_DashQuest:SetScript('OnLeave', addon.HideTooltip) -- Social -- local function GUI_DashSocial_OnEnter(self) GUI_ToolTipSetup(self) local numBNetFriends, numBNetOnline = BNGetNumFriends(); local numWoWFriends, numWoWOnline = GetNumFriends(); local sPlural = "s"; if (numBNetOnline + numWoWOnline) == 1 then sPlural = ""; end GameTooltip:AddLine(MicroButtonTooltipText(SOCIALS ,"TOGGLESOCIAL")); GameTooltip:AddLine(" ") GameTooltip:AddLine((numBNetOnline + numWoWOnline) .. " Friend" .. sPlural .. " Online", 0, 1, 0); -- Battle.net Friends for i = 1, numBNetFriends, 1 do local sPresenceID, sNameFirst, sNameLast, sCharName, sCharID, sClient, bIsOnline = BNGetFriendInfo(i); if bIsOnline then local sArea = sClient; if sClient == "WoW" then local _, _, _, sServer = BNGetToonInfo(sPresenceID); sArea = sServer; end GameTooltip:AddLine(sCharName .. " (" .. sArea .. ") [" .. sNameFirst .. " " .. sNameLast .. "]", 0, 1, 1 ); end end -- Regular Friends for i = 1, numWoWFriends, 1 do local sName, iLevel, sClass, sArea, bConnected, sNote, fStatus = GetFriendInfo(i); local color = colors[CLASS[sClass]] if bConnected then GameTooltip:AddLine(sName, color.r, color.g, color.b); end end if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashSocial:SetScript('OnEnter', GUI_DashSocial_OnEnter) GUI_DashSocial:SetScript('OnLeave', addon.HideTooltip) -- Guild -- local function GUI_DashGuild_OnEnter(self) GUI_ToolTipSetup(self) GameTooltip:AddLine(MicroButtonTooltipText(GUILD, "TOGGLEGUILDTAB")); GameTooltip:AddLine(" ") if IsInGuild() == nil then GameTooltip:AddLine("Not in a Guild") else local total = GetNumGuildMembers(true) local onlineTotal = 0 local offlineTotal = 0 for i = 1, total do local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(i) if online and name ~= GetUnitName("player") then onlineTotal = onlineTotal + 1 else offlineTotal = offlineTotal + 1 end end local sPlural = "s"; if onlineTotal == 1 then sPlural = ""; end GameTooltip:AddLine((onlineTotal) .. " Guildie" .. sPlural .. " Online", 0, 1, 0); for index = 1, total, 1 do local gName, gRank,_, gLevel, gClass,_,_,_, gConnected, gStatus, gFileName = GetGuildRosterInfo(index); local color = colors[CLASS[gClass]] if gConnected and gName ~= GetUnitName("player") then GameTooltip:AddLine(gName, color.r, color.g, color.b); end end end if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashGuild:SetScript('OnEnter', GUI_DashGuild_OnEnter) GUI_DashGuild:SetScript('OnLeave', addon.HideTooltip) -- Money -- local moneyGained, moneySpent = 0, 0 local function GUI_DashMoney_OnEnter(self) local tooltip = GameTooltip GUI_ToolTipSetup(self) tooltip:AddLine("Cash flow:") if moneyGained > 0 or moneySpent > 0 then tooltip:AddLine(" ") tooltip:AddLine("This session") tooltip:AddDoubleLine("Gained", addon:MoneyToString(moneyGained, true), 1, 1, 1, 1, 1, 1) tooltip:AddDoubleLine("Spent", addon:MoneyToString(moneySpent, true), 1, 1, 1, 1, 1, 1) if moneyGained - moneySpent > 0 then tooltip:AddDoubleLine(" ", "|cff00ff00(+)|r " .. addon:MoneyToString(moneyGained - moneySpent, true), 1, 1, 1, 1, 1, 1) else tooltip:AddDoubleLine(" ", "|cffff0000(-)|r " .. addon:MoneyToString(moneySpent - moneyGained, true), 1, 1, 1, 1, 1, 1) end end tooltip:AddLine(" ") local total, colors, color = 0, CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS for name, settings in pairs(_G[addonName .. "Settings"][GetRealmName()]) do color = colors[settings.class] tooltip:AddDoubleLine(name, addon:MoneyToString(settings.money, true), color.r, color.g, color.b, 1, 1, 1) if type(settings.money) ~= 'number' then settings.money = 0 end total = total + settings.money end tooltip:AddLine(" ") tooltip:AddDoubleLine("Total", addon:MoneyToString(total, true), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1, 1, 1) if not self.tooltip then GameTooltip:Show() self.tooltip = true end end GUI_DashMoney:SetScript("OnEnter", GUI_DashMoney_OnEnter) GUI_DashMoney:SetScript('OnLeave', addon.HideTooltip) --[[----------------------------------------------------------------------------- OnUpdate Functions -------------------------------------------------------------------------------]] -- Speed -- GUI_DashSpeed:SetScript('OnUpdate', function(self) local s = string.format("%d%%", (GetUnitSpeed("Player") / 7) * 100); GUI_DashSpeed.text:SetText(s) end) -- Clock -- function addon:SetClockHrFormat() if addon.settings.clock24hr == false then clock.text:SetText(("%d:%s"):format(tonumber(date("%I")), date("%M%p"):lower())) else clock.text:SetText(server_hour .. ":" .. server_minute) end end local previousMinute, timer = -1, 5 clock:SetScript('OnUpdate', function(self, elapsed) timer = timer + elapsed if timer < 5 then return end timer = 0 server_hour, server_minute = GetGameTime() if server_minute == previousMinute then return end previousMinute = server_minute addon:SetClockHrFormat() if self.tooltip then self.tooltip = nil GUI_DashClock_OnEnter() end end) -- Latency -- local timer = 10 GUI_DashLatency:SetScript('OnUpdate', function(self, elapsed) timer = timer + elapsed if timer < PERFORMANCEBAR_UPDATE_INTERVAL then return end timer = 0 local _, _, latency = GetNetStats() GUI_DashLatency.text:SetTextColor(min(latency / LATENCY_MID_RANGE, 1), 1 - min(max(latency - LATENCY_MID_RANGE, 0) / LATENCY_MID_RANGE, 1), 0) GUI_DashLatency.text:SetFormattedText("%sms", latency) end) -- FPS -- local timer = 1 GUI_DashFPS:SetScript('OnUpdate', function(self, elapsed) timer = timer + elapsed if timer < 1 then return end timer = 0 local fps = floor(GetFramerate() + 0.5) GUI_DashFPS.text:SetTextColor(1 - min(max(fps - FPS_MID_RANGE, 0) / FPS_MID_RANGE, 1), min(fps / FPS_MID_RANGE, 1), 0) GUI_DashFPS.text:SetFormattedText("%sfps", fps) end) --[[----------------------------------------------------------------------------- OnClick Functions -------------------------------------------------------------------------------]] -- Clock -- clock:SetScript('OnClick', function(self, button) if button == 'LeftButton' then ToggleTimeManager() else ToggleCalendar() end end) -- Durability -- GUI_DashDurability:SetScript('OnClick', function(self, button) if button == 'LeftButton' then if addon.settings.autoRepair == true then addon.settings.autoRepair = false UIErrorsFrame:AddMessage("Auto-Repair: Off", 1, 0, 0, 53, 3); elseif addon.settings.autoRepair == false then addon.settings.autoRepair = true UIErrorsFrame:AddMessage("Auto-Repair: On", 0, 1, 0, 53, 3); end self.tooltip = nil GUI_DashDurability_OnEnter(self) end if button == 'RightButton' then if addon.settings.GuildRepair == true then addon.settings.GuildRepair = false UIErrorsFrame:AddMessage("Guild-Repair: Off", 1, 0, 0, 53, 3); elseif addon.settings.GuildRepair == false then addon.settings.GuildRepair = true UIErrorsFrame:AddMessage("Guild-Repair: On", 0, 1, 0, 53, 3); end self.tooltip = nil GUI_DashDurability_OnEnter(self) end end) -- Inventory -- GUI_DashInventory:SetAttribute('_onclick', [[ if button == 'LeftButton' then control:CallMethod("ToggleBags") else local bagBar = self:GetFrameRef("bagBar") if bagBar:IsVisible() then bagBar:Hide() else bagBar:Show() end end ]]) function GUI_DashInventory:ToggleBags() if Baggins then Baggins:ToggleBackpack() else if ContainerFrame1:IsShown() then CloseAllBags() else OpenAllBags() end end end -- Social -- GUI_DashSocial:SetScript('OnClick', function(self) ToggleFriendsFrame() end) -- Guild -- GUI_DashGuild:SetScript('OnClick', function(self, button) ToggleGuildFrame() end) -- Quest -- GUI_DashQuest:SetScript('OnClick', function(self) ToggleFrame(QuestLogFrame) end) --[[----------------------------------------------------------------------------- OnEvent Functions -------------------------------------------------------------------------------]] -- Mail -- local function GUI_DashMail_Init(self, event) GUI_DashMail.text:SetText(addon.settings.CurrentMail) end local function GUI_DashMail_OnEvent(self, event) if HasNewMail() then GUI_DashMail.text:SetTextColor(0, 1, 0) GUI_DashMail.texture:SetVertexColor(0, 1, 0) else GUI_DashMail.text:SetTextColor(1, 1, 1) GUI_DashMail.texture:SetVertexColor(1, 1, 1) end if event == "MAIL_INBOX_UPDATE" then GUI_DashMail.text:SetText(GetInboxNumItems()) addon.settings.CurrentMail = GetInboxNumItems() end if GUI_DashMail.tooltip then MinimapMailFrameUpdate() end end -- Quests -- local function GUI_DashQuest_OnEvent(self, event) local numEntries, numQuests = GetNumQuestLogEntries() GUI_DashQuest.text:SetFormattedText("%s/25", numQuests) end -- Durability -- function GUI_DashDurability:UpdatePercent() local tPer = floor(pEquipDura.min / pEquipDura.max * 100) GUI_DashDurability.text:SetText(addon:DurColor(tPer)..tPer.."%|r"); end local function GUI_DashDurability_OnEvent(self, event) GUI_DashDurability:GetDurabilityInfo() GUI_DashDurability:UpdatePercent() end addon.RegisterEvent("DashBoard-AutoRepair", 'MERCHANT_SHOW', function() if addon.settings.autoRepair and CanMerchantRepair() then if addon.settings.GuildRepair == true then local cost = GetRepairAllCost() if cost > 0 and cost <= GetMoney() then RepairAllItems(1) print("|cff33ff99" .. addonName .. "|r: Repaired all equipment for " .. addon:MoneyToString(cost) .."(Guild Funds)") end else local cost = GetRepairAllCost() if cost > 0 and cost <= GetMoney() then RepairAllItems() print("|cff33ff99" .. addonName .. "|r: Repaired all equipment for " .. addon:MoneyToString(cost) .. "(Your Funds)") end end end end) -- Inventory -- local function GUI_DashInventory_OnEvent(self, event) local free, total = 0, 0 for bag = 0, NUM_BAG_FRAMES do free = free + GetContainerNumFreeSlots(bag) total = total + GetContainerNumSlots(bag) end local freePercent = floor(free / total * 100 + 0.5) local BAG_SPACE_MID_RANGE = (total / 2) GUI_DashInventory.text:SetTextColor(1 - min(max(freePercent - BAG_SPACE_MID_RANGE, 0) / BAG_SPACE_MID_RANGE, 1), min(freePercent / BAG_SPACE_MID_RANGE, 1), 0) GUI_DashInventory.text:SetFormattedText("%s/%s", free, total) end GUI_DashInventory:SetScript('OnEvent', function(self) GUI_DashInventory_OnEvent() end) -- Money -- local LDBObj local function GUI_DashMoney_OnEvent(self, event) GUI_DashMoney:SetWidth(0) GUI_DashMoney.text:SetText(addon:MoneyToString(GetMoney(), true)) GUI_DashMoney:SetWidth(GUI_DashMoney.text:GetStringWidth()) end local function GUI_DashMoney_Init(self, event) if type(addon.settings.money) ~= 'number' then addon.settings.money = GetMoney() or 0 end addon:RegisterDefaultSetting("money", 0) if LDBObj then LDBObj.text = addon:MoneyToString(addon.settings.money, true) end end -- Clock -- local function GetInvites() if CalendarGetNumPendingInvites() ~= 0 then clock.texture:Show() else clock.texture:Hide() end if CalendarFrame and CalendarFrame:IsShown() then clock.texture:Hide() end end local function GetGuildEvents() local numguildEvents = CalendarGetNumGuildEvents() local currentweekday, currentmonth, currentday, currentyear = CalendarGetDate() for eventIndex = 1, numguildEvents do local month, day, weekday, hour, minute, eventType, title, calendarType, textureName = CalendarGetGuildEventInfo(eventIndex) local monthOffset = month - currentmonth local numEvents = CalendarGetNumDayEvents(monthOffset, day) if numEvents ~= 0 then clock.texture:Show() else clock.texture:Hide() end end if CalendarFrame and CalendarFrame:IsShown() then clock.texture:Hide() end end local function GUI_DashClock_Init(self, event) local _, todaysmonth, _, todaysyear = CalendarGetDate() CalendarSetAbsMonth(todaysmonth, todaysyear) OpenCalendar() GetInvites() GetGuildEvents() end local function GUI_DashClock_OnEvent(self, event) GetInvites() GetGuildEvents() end -- Social/Friends -- local function GUI_DashSocial_OnEvent(self, event) local numberOfFriends, onlineFriends = GetNumFriends() local BNnumberOfFriends, BNonlineFriends = BNGetNumFriends() if onlineFriends > 0 then GUI_DashSocial.text:SetTextColor(0, 1, 0) elseif BNonlineFriends > 0 then GUI_DashSocial.text:SetTextColor(0, 1, 0) else GUI_DashSocial.text:SetTextColor(1, 1, 1) end GUI_DashSocial.text:SetText(onlineFriends + BNonlineFriends) if GUI_DashSocial.tooltip then FriendsList_Update() end end -- Guild Frame -- local function GUI_DashGuild_OnEvent(self, event) GuildRoster() local total = GetNumGuildMembers(true) local onlineTotal = 0 local offlineTotal = 0 for i = 1, total do local name, rank, rankIndex, level, class, zone, note, officernote, online, status, classFileName = GetGuildRosterInfo(i) if online and name ~= GetUnitName("player") then onlineTotal = onlineTotal + 1 else offlineTotal = offlineTotal + 1 end end if onlineTotal > 0 then GUI_DashGuild.text:SetTextColor(0, 1, 0) else GUI_DashGuild.text:SetTextColor(1, 1, 1) end GUI_DashGuild.text:SetText(onlineTotal) if IsInGuild() == nil then GUI_DashGuild.texture1:Show() GUI_DashGuild.texture2:Show() else GUI_DashGuild.texture1:Hide() GUI_DashGuild.texture2:Hide() end end --[[----------------------------------------------------------------------------- DashBoard Layout -------------------------------------------------------------------------------]] function addon:DashLayout() if not addon.settings.dashOnTop or addon.settings.dashOnTop == false then DashBoardFrame:ClearAllPoints() DashBoardFrame:SetPoint('TOPRIGHT', addon.skin, 'TOPRIGHT', -20, -11) DashBoardFrame:SetHeight(200) DashBoardFrame:SetWidth(500) DBFbg:SetTexture(0, 0, 0, 0) clock:SetPoint('TOPRIGHT', DashBoardFrame, 'TOPRIGHT', 0, 0) GUI_DashSocial:SetPoint('RIGHT', clock, 'LEFT', 0, 0) GUI_DashGuild:SetPoint('RIGHT', GUI_DashSocial, 'LEFT', 0, 0) GUI_DashQuest:SetPoint('RIGHT', GUI_DashGuild, 'LEFT', -5, 0) GUI_DashInventory:SetPoint('RIGHT', GUI_DashQuest, 'LEFT') GUI_DashMail:ClearAllPoints() GUI_DashMail:SetPoint('TOPRIGHT', clock, 'BOTTOMRIGHT', 0, -2) if addon.settings.speedShow == true then GUI_DashSpeed:Show() GUI_DashSpeed:SetPoint('RIGHT', GUI_DashMail, 'LEFT', 0, 0) GUI_DashDurability:SetPoint('RIGHT', GUI_DashSpeed, 'LEFT', -5, 0) GUI_DashMoney:SetPoint('RIGHT', GUI_DashDurability, 'LEFT') elseif addon.settings.speedShow == false then GUI_DashSpeed:Hide() GUI_DashDurability:SetPoint('RIGHT', GUI_DashMail, 'LEFT', -5, 0) GUI_DashMoney:SetPoint('RIGHT', GUI_DashDurability, 'LEFT') end if addon.settings.latencyShow == true then GUI_DashLatency:Show() GUI_DashFPS:Show() GUI_DashLatency:ClearAllPoints() GUI_DashLatency:SetPoint('TOPRIGHT', GUI_DashMail, 'BOTTOMRIGHT', 0, 0) GUI_DashFPS:SetPoint('RIGHT', GUI_DashLatency, 'LEFT') elseif addon.settings.latencyShow == false then GUI_DashLatency:Hide() GUI_DashFPS:Hide() end else DashBoardFrame:ClearAllPoints() DashBoardFrame:SetPoint('TOP', UIParent, 'TOP', 0, 0) DashBoardFrame:SetHeight(20) DBFbg:SetTexture(0, 0, 0, .7) clock:SetPoint('TOPRIGHT', DashBoardFrame, 'TOPRIGHT', 0, 0) GUI_DashGuild:SetPoint('RIGHT', GUI_DashSocial, 'LEFT', 0, 0) GUI_DashQuest:SetPoint('RIGHT', GUI_DashGuild, 'LEFT', -5, 0) GUI_DashDurability:SetPoint('RIGHT', GUI_DashQuest, 'LEFT', -5, 0) GUI_DashInventory:SetPoint('RIGHT', GUI_DashDurability, 'LEFT') GUI_DashMoney:SetPoint('RIGHT', GUI_DashInventory, 'LEFT') if addon.settings.latencyShow == true and addon.settings.speedShow == false then DashBoardFrame:SetWidth(570) elseif addon.settings.latencyShow == false and addon.settings.speedShow == true then DashBoardFrame:SetWidth(520) elseif addon.settings.latencyShow == false and addon.settings.speedShow == false then DashBoardFrame:SetWidth(475) else DashBoardFrame:SetWidth(620) end if addon.settings.speedShow == true then GUI_DashSpeed:Show() GUI_DashSpeed:SetPoint('RIGHT', GUI_DashMail, 'LEFT', 0, 0) GUI_DashSocial:SetPoint('RIGHT', GUI_DashSpeed, 'LEFT', 0, 0) elseif addon.settings.speedShow == false then GUI_DashSpeed:Hide() GUI_DashSocial:SetPoint('RIGHT', GUI_DashMail, 'LEFT', -5, 0) end if addon.settings.latencyShow == true then GUI_DashLatency:Show() GUI_DashFPS:Show() GUI_DashLatency:ClearAllPoints() GUI_DashLatency:SetPoint('RIGHT', clock, 'LEFT', 0, 0) GUI_DashFPS:SetPoint('RIGHT', GUI_DashLatency, 'LEFT') GUI_DashMail:ClearAllPoints() GUI_DashMail:SetPoint('RIGHT', GUI_DashFPS, 'LEFT', 0, -2) elseif addon.settings.latencyShow == false then GUI_DashMail:ClearAllPoints() GUI_DashMail:SetPoint('RIGHT', clock, 'LEFT', 0, -2) GUI_DashLatency:Hide() GUI_DashFPS:Hide() end end -- set scale DashBoardFrame:SetScale(addon.settings.dashboardScale) end addon.RegisterEvent("DashBoard-Initialize", 'PLAYER_ENTERING_WORLD', function(self, event) addon.UnregisterEvent(self, event) addon:DashLayout() GUI_DashMoney_Init(event) GUI_DashMoney_OnEvent() GUI_DashClock_Init(event) GUI_DashGuild_OnEvent() GUI_DashSocial_OnEvent() GUI_DashInventory_OnEvent() GUI_DashMail_Init() GUI_DashMail_OnEvent(event) GUI_DashQuest_OnEvent() GUI_DashDurability_OnEvent() end) addon.RegisterEvents("DashBoardFrame", GUI_DashMail_OnEvent, 'MAIL_INBOX_UPDATE', 'UPDATE_PENDING_MAIL') addon.RegisterEvents("DashBoardFrame", GUI_DashQuest_OnEvent, 'QUEST_LOG_UPDATE') addon.RegisterEvents("DashBoardFrame", GUI_DashDurability_OnEvent, 'UPDATE_INVENTORY_ALERTS', 'UPDATE_INVENTORY_DURABILITY', 'UNIT_INVENTORY_CHANGED', 'MERCHANT_CLOSED', 'PLAYER_DEAD', 'PLAYER_REGEN_ENABLED') addon.RegisterEvents("DashBoardFrame", GUI_DashInventory_OnEvent, 'UNIT_INVENTORY_CHANGED', 'BAG_UPDATE') addon.RegisterEvents("DashBoardFrame", GUI_DashMoney_OnEvent, 'PLAYER_MONEY') addon.RegisterEvents("DashBoardFrame", GUI_DashClock_OnEvent, 'CALENDAR_UPDATE_PENDING_INVITES', 'CALENDAR_UPDATE_EVENT_LIST') addon.RegisterEvents("DashBoardFrame", GUI_DashSocial_OnEvent, 'FRIENDLIST_UPDATE', 'BN_FRIEND_ACCOUNT_ONLINE', 'BN_FRIEND_ACCOUNT_OFFLINE') addon.RegisterEvents("DashBoardFrame", GUI_DashGuild_OnEvent, 'GUILD_ROSTER_UPDATE', 'PLAYER_GUILD_UPDATE') --[[----------------------------------------------------------------------------- Money tooltip overrides -------------------------------------------------------------------------------]] addon.RegisterEvent("DashBoard-MoneyTooltip-Update", 'PLAYER_MONEY', function() local money = GetMoney() local diff = money - addon.settings.money if diff > 0 then moneyGained = moneyGained + diff else moneySpent = moneySpent - diff end addon.settings.money = money if LDBObj then LDBObj.text = addon:MoneyToString(money, true) end end) -- Simple bag frame support: -- true means multiple frames and reanchoring -- false means a single frame local bagNames = { ['ContainerFrame1MoneyFrame'] = true, -- Blizzard Backpack ['MerchantMoneyFrame'] = true, -- Blizzard Merchant Frame ['OneBagFrameMoneyFrame'] = true, -- OneBag ['BagginsMoneyFrame'] = false, -- Baggins ['CombuctorFrame1MoneyFrameClick'] = false, -- Combuctor Bag ['CombuctorFrame2MoneyFrameClick'] = false, -- Combuctor Bank ['ARKINV_Frame1StatusGold'] = true, -- ArkInventory Bag ['ARKINV_Frame3StatusGold'] = true, -- ArkInventory Bank ['BBCont1_1MoneyFrame'] = true, -- BaudBag bag ['BBCont2_1MoneyFrame'] = true, -- BaudBag bank ['FBoH_BagViewFrame_1_GoldFrame'] = true, -- FBoH ['FBoH_BagViewFrame_2_GoldFrame'] = true, -- FBoH ['BagnonMoney0'] = true, -- Bagnon ['BagnonMoney1'] = true, -- Bagnon ['TokenFrameMoneyFrame'] = true, -- GUI } local cargBagsHooked, frames = false, {} addon.RegisterEvent("DashBoard-MoneyTooltipHooks", 'ADDON_LOADED', function(self, event) if cargBags and not cargBagsHooked then cargBagsHooked = true for _, object in pairs(cargBags.Objects) do if object.Money then bagNames[object.Money:GetName()] = true end end end for name, hasCoins in pairs(bagNames) do if _G[name] then frames[#frames + 1] = _G[name] if hasCoins then frames[#frames + 1] = _G[name .. 'CopperButton'] frames[#frames + 1] = _G[name .. 'SilverButton'] frames[#frames + 1] = _G[name .. 'GoldButton'] _G[name .. 'CopperButton'].tooltipAnchor = _G[name] _G[name .. 'SilverButton'].tooltipAnchor = _G[name] _G[name .. 'GoldButton'].tooltipAnchor = _G[name] end bagNames[name] = nil end end for index = #frames, 1, -1 do local frame = frames[index] frame:EnableMouse(true) frame:HookScript('OnEnter', GUI_DashMoney_OnEnter) frame:HookScript('OnLeave', addon.HideTooltip) frames[index] = nil end if not LDBObj and LibStub and LibStub('LibDataBroker-1.1', true) then LDBObj = LibStub('LibDataBroker-1.1'):NewDataObject(addonName .. "Money", { type = 'data source', label = addonName .. "Money", OnEnter = OnEnter, OnLeave = addon.HideTooltip }) end if next(bagNames) then return end addon.UnregisterEvent(self, event) end) Last edited by Grimsin : 01-29-12 at 11:03 AM. |
|
![]() |
01-29-12, 10:46 AM | #6 |
My eyes!! Code tags please
![]() |
|
![]() |
01-31-12, 09:13 PM | #7 |
I FOUND IT!!!!!!!!!!!!!!!!!!!!!!! Well i figured out where the problem code is anyhow... what the exact problem is is still currently beyond me but the cause of the dcing is in this code here -
Code:
local addonName, addon = ... --[[----------------------------------------------------------------------------- Configure Rep and Exp bars -------------------------------------------------------------------------------]] function addon:ConfigureExpBar() if addon.settings.showExpBar == true then addon:ShowFrame("GrimExpBar") _G["GrimRepBar"]:ClearAllPoints() _G["GrimRepBar"]:SetPoint('TOPRIGHT', "GrimExpBar", "BOTTOMRIGHT", 0, 0) else addon:HideFrame("GrimExpBar") if GUI_PlayerMana ~= nil then _G["GrimRepBar"]:ClearAllPoints() _G["GrimRepBar"]:SetPoint('TOPRIGHT', "GUI_PlayerMana", "BOTTOMRIGHT", 0, 0) else _G["GrimRepBar"]:ClearAllPoints() _G["GrimRepBar"]:SetPoint('LEFT', UIParent, "LEFT", 0, 0) end end end function addon:ConfigureRepBar() if addon.settings.showRepBar == true then addon:ShowFrame("GrimRepBar") else addon:HideFrame("GrimRepBar") end end --------------------------- -- Xp Bar ----------------------- local GrimExpBar = CreateFrame('button', "GrimExpBar", UIParent) GrimExpBar:RegisterEvent("PLAYER_XP_UPDATE") GrimExpBar:RegisterEvent("PLAYER_LEVEL_UP", "level") GrimExpBar:RegisterEvent("UPDATE_EXHAUSTION") GrimExpBar:RegisterEvent("UNIT_PET", "player") GrimExpBar:RegisterEvent("UNIT_PET_EXPERIENCE", "player") GrimExpBar:RegisterEvent("PLAYER_GUILD_UPDATE") GrimExpBar:RegisterEvent("GUILD_XP_UPDATE") GrimExpBar:SetHeight(20) GrimExpBar:SetWidth(235) GrimExpBar:SetFrameStrata("HIGH") GrimExpBar:SetFrameLevel("4") local xpBar = CreateFrame("StatusBar", nil, GrimExpBar, "TextStatusBar") xpBar:SetAllPoints("GrimExpBar") xpBar:SetStatusBarTexture([[Interface\AddOns\]] .. addonName .. [[\Media\BarTexture]]) xpBar:SetStatusBarColor(0.5, 0.1, 0.9, 1) xpBar:SetFrameLevel("3") local xpText = xpBar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") xpText:SetPoint("LEFT", GrimExpBar, "LEFT", 3, -2) xpText:SetTextColor(1, 1, 1, 1) xpText:SetFont([[Interface\AddOns\]] .. addonName .. [[\Media\Font-1.ttf]], 11.5, "OUTLINE") local restXPbar = CreateFrame("StatusBar", nil, GrimExpBar, "TextStatusBar") restXPbar:SetAllPoints("GrimExpBar") restXPbar:SetStatusBarTexture([[Interface\AddOns\]] .. addonName .. [[\Media\BarTexture]]) restXPbar:SetStatusBarColor(.290, .305, .878, 1) restXPbar:SetFrameLevel("2") local bg = xpBar:CreateTexture(nil, "BACKGROUND") bg:SetTexture(0, 0, 0, 0) bg:SetAllPoints("GrimExpBar") local function GXPBarEvent() local currXP, nextXP = UnitXP("Player"), UnitXPMax("Player") local leftXP = (nextXP - currXP) local _, myClass = UnitClass("Player") local petXPcur, petXPnex = GetPetExperience() local petXPleft = (petXPnex - petXPcur) local restXP, percentXP = GetXPExhaustion(), floor(currXP / nextXP * 100) local str QueryGuildXP() local currentXP, nextLevelXP, dailyXP, maxDailyXP, unitWeeklyXP, unitTotalXP = UnitGetGuildXP("player") local GXPTot = (nextLevelXP + currentXP) local GleftXP = (nextLevelXP - currentXP) if addon.settings.showGuild == true then if addon.settings.xpBarvar == "xpLeft" then str = ("%s left - Guild"):format(nextLevelXP) elseif addon.settings.xpBarvar == "xpTot" then str = ("%s/%s Guild"):format(currentXP, GXPTot) end xpText:SetText(str) xpBar:SetMinMaxValues(min(0, currentXP), GXPTot) xpBar:SetValue(currentXP) if maxDailyXP ~= nil then restXPbar:SetMinMaxValues(min(0, currentXP), maxDailyXP) -- dont forget restXP must be a value or nil must be delt with restXPbar:SetValue(maxDailyXP) -- dont forget restXP must be a value or nil must be delt with end else if restXP == nil then -- nill is being delt with if addon.settings.xpBarvar == "xpLeft" and myClass == "HUNTER" then str = ("%s left %s Pet"):format(leftXP, petXPleft) elseif addon.settings.xpBarvar == "xpLeft" and myClass ~= "HUNTER" then str = ("%s left "):format(leftXP) elseif addon.settings.xpBarvar == "xpTot" and myClass == "HUNTER" then str = ("%s/%s P %s/%s"):format(currXP, nextXP, petXPcur, petXPnex) elseif addon.settings.xpBarvar == "xpTot" and myClass ~= "HUNTER" then str = ("%s/%s "):format(currXP, nextXP) end restXPbar:SetMinMaxValues(min(0, currXP), nextXP) -- dont forget restXP must be a value or nil must be delt with restXPbar:SetValue(currXP) -- dont forget restXP must be a value or nil must be delt with else local percentRestXP = floor(restXP / nextXP * 100) if addon.settings.xpBarvar == "xpLeft" and myClass == "HUNTER" then str = ("%s left (%s %s%%R) P %s"):format(leftXP, restXP, percentRestXP, petXPleft) elseif addon.settings.xpBarvar == "xpLeft" and myClass ~= "HUNTER" then str = ("%s left (%s %s%%R)"):format(leftXP, restXP, percentRestXP) elseif addon.settings.xpBarvar == "xpTot" and myClass == "HUNTER" then str = ("%s/%s (%s%%R) P %s/%s"):format(currXP, nextXP, percentRestXP, petXPcur, petXPnex) elseif addon.settings.xpBarvar == "xpTot" and myClass ~= "HUNTER" then str = ("%s/%s (%s%%R)"):format(currXP, nextXP, percentRestXP) end restXPbar:SetMinMaxValues(min(0, restXP), nextXP) -- dont forget restXP must be a value or nil must be delt with restXPbar:SetValue(currXP + restXP) -- dont forget restXP must be a value or nil must be delt with end xpText:SetText(str) xpBar:SetMinMaxValues(min(0, currXP), nextXP) xpBar:SetValue(currXP) end end GrimExpBar:SetScript("OnEvent", function(self) GXPBarEvent() end) GrimExpBar:RegisterForClicks('LeftButtonUp', 'RightButtonUp') GrimExpBar:SetScript('OnClick', function(self, button) if button == "LeftButton" then if addon.settings.xpBarvar == "xpLeft" then addon.settings.xpBarvar = "xpTot" elseif addon.settings.xpBarvar == "xpTot" then addon.settings.xpBarvar = "xpLeft" end GrimExpBar:GetScript("OnEvent")(GrimExpBar) else if addon.settings.showGuild == false then addon.settings.showGuild = true elseif addon.settings.showGuild == true then addon.settings.showGuild = false end GrimExpBar:GetScript("OnEvent")(GrimExpBar) end end) ------------------------------ -- Rep Bar ------------------------------ local GrimRepBar = CreateFrame('button', "GrimRepBar", UIParent) GrimRepBar:RegisterEvent("UPDATE_FACTION") GrimRepBar:SetHeight(20) GrimRepBar:SetWidth(235) GrimRepBar:SetFrameStrata("HIGH") GrimRepBar:SetFrameLevel("4") local repBar = CreateFrame("StatusBar", nil, GrimRepBar, "TextStatusBar") repBar:SetAllPoints("GrimRepBar") repBar:SetStatusBarTexture([[Interface\AddOns\]] .. addonName .. [[\Media\BarTexture]]) repBar:SetFrameLevel("3") local repText = repBar:CreateFontString(nil, "OVERLAY", "GameFontNormalSmall") repText:SetPoint("LEFT", GrimRepBar, "LEFT", 3, -2) repText:SetTextColor(1, 1, 1, 1) repText:SetFont([[Interface\AddOns\]] .. addonName .. [[\Media\Font-1.ttf]], 11.5, "OUTLINE") local function GREPBarEvent() local factionRep, curStanding, minRep, maxRep, curRep = GetWatchedFactionInfo() local leftRep = (maxRep - curRep) if factionRep == nil then repText:SetText("No Watched Faction") elseif factionRep ~= nil then if addon.settings.repBarvar == "repTot" then repstr = ("%s/%s %s"):format(curRep, maxRep, factionRep) elseif addon.settings.repBarvar == "repLeft" then repstr = ("%s left - %s"):format(leftRep, factionRep) end repText:SetText(repstr) end repBar:SetMinMaxValues(min(0, curRep), maxRep) repBar:SetValue(curRep) repBar:SetStatusBarColor(0.5, 0.1, 0.9, 1) end GrimRepBar:SetScript("OnEvent", function(self) GREPBarEvent() end) GrimRepBar:RegisterForClicks('LeftButtonUp', 'RightButtonUp') GrimRepBar:SetScript('OnClick', function(self, button) if button == "LeftButton" then if addon.settings.repBarvar == "repLeft" then addon.settings.repBarvar = "repTot" elseif addon.settings.repBarvar == "repTot" then addon.settings.repBarvar = "repLeft" end GrimRepBar:GetScript("OnEvent")(GrimRepBar) end end) function addon:ResetExpRepBar() if GUI_PlayerMana ~= nil then _G["GrimExpBar"]:ClearAllPoints() _G["GrimExpBar"]:SetPoint('TOPRIGHT', 'GUI_PlayerMana', "BOTTOMRIGHT", 0, 0) else _G["GrimExpBar"]:ClearAllPoints() _G["GrimExpBar"]:SetPoint('LEFT', UIParent, "LEFT", 0, 0) end if addon.settings.showExpBar then _G["GrimRepBar"]:ClearAllPoints() _G["GrimRepBar"]:SetPoint('TOPRIGHT', "GrimExpBar", "BOTTOMRIGHT", 0, 0) else if GUI_PlayerMana ~= nil then _G["GrimRepBar"]:ClearAllPoints() _G["GrimRepBar"]:SetPoint('TOPRIGHT', "GUI_PlayerMana", "BOTTOMRIGHT", 0, 0) else _G["GrimRepBar"]:ClearAllPoints() _G["GrimRepBar"]:SetPoint('LEFT', UIParent, "LEFT", 0, 0) end end end --[[----------------------------------------------------------------------------- Initialize -------------------------------------------------------------------------------]] addon.RegisterEvent("InitializeExpRepBar", 'PLAYER_ENTERING_WORLD', function(self, event) addon.UnregisterEvent(self, event) addon:ResetExpRepBar() addon:ConfigureExpBar() addon:ConfigureRepBar() GXPBarEvent() GREPBarEvent() ToggleGuildFrame() ToggleGuildFrame() end) |
|
![]() |
01-31-12, 11:50 PM | #8 |
That above code worked until i added the stuff for showing guild xp so hmm maybe the issue is there? Maybe on bliz's end? As i dont see anything wrong with this code other then thats a big function calling pretty frequently... but still its not like i hooked it to an onupdate
![]() |
|
![]() |
02-01-12, 01:17 AM | #9 |
And the culprit is!! DUN DUN DUN !!!!! QueryGuildXP() !!!!!
not good to use in a function that runs repeatedly. |
|
![]() |
02-01-12, 02:05 AM | #10 |
Ah - yes. Any function that queries the server is a likely candidate for disconnection when spammed. I'd call it on a timer, and get the results via GUILD_XP_UPDATE.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Author of NPCScan and many other AddOns. |
|
![]() |
02-01-12, 02:45 AM | #11 |
Im not sure i understand what you mean by get the results from the event? I removed that queryfunc and the guild xp seems to be updating but its not exactly when you would think it should... which is why i had put that in there to begin with, it updates when ever i open the guild frame and then at other seemingly random times. So what your saying is setup a function on a timer like an onupdate? or? I think to better understand this, why is it that when i do getguildxp it requires the query be made to bring back the right xp amount? Why does that not get the correct amount when ever the guild_xp_update fires to begin with?
|
|
![]() |
WoWInterface » Developer Discussions » General Authoring Discussion » a problem that causes disconnect but no errors |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
![]() |
![]() |
![]() |
|
|