07-20-10, 05:30 PM | #1 |
Forced Item Server Query
So, Carbonite and atlasloot apparently can force server queries for item data.
Does this include quality and type(s) data? If so, how is this accomplished? I tried poking around in them a bit, but between the number of files and libs, it's a bit like looking for a cheeseburger in fat camp..... |
|
07-20-10, 05:31 PM | #2 |
you have to add the item to a tooltip and then once the tooltip gets populated you have all the info about the item
this is what i use in YssBossLoot Code:
local _, YssBossLoot = ... local L = LibStub("AceLocale-3.0"):GetLocale("YssBossLoot", true) local timerFrame = CreateFrame("Frame") local animationGroup = timerFrame:CreateAnimationGroup() local animation = animationGroup:CreateAnimation("Animation") animation:SetDuration(7) -- increase this number if this Scanner starts disconnecting people without outside interference 6 seams to be the minimum lets use 7 to keep a little buffer animationGroup:SetLooping("NONE") local Scanner = CreateFrame("GameTooltip", "YssBossLoot_ScannerTooltip", nil, "GameTooltipTemplate") Scanner:SetOwner(UIParent, "ANCHOR_NONE") local itemlist = {} local query_item local function QueryNextItem() if next(itemlist) then query_item = tremove(itemlist, 1) -- always pull from bottom of table (its expensive but ensures order also makes adding items inexpensive and spreads out the expensive operation) if GetItemInfo(query_item) then -- if we already know item no need to query for it we just move on to the next item on the list YssBossLoot:UpdateLoot(#itemlist, query_item) return QueryNextItem() else YssBossLoot:UpdateLoot(#itemlist) end Scanner:SetHyperlink('item:'..query_item) else query_item = nil YssBossLoot:UpdateLoot(0) end end local function OnTooltipSetItem() if not query_item then return end if GetItemInfo(query_item) then -- if we already know item no need to query for it we just move on to the next item on the list YssBossLoot:UpdateLoot(#itemlist, query_item) if animationGroup:IsPlaying() then animationGroup:Stop() end QueryNextItem() else animationGroup:Play() end end animationGroup:SetScript("OnFinished", QueryNextItem) Scanner:SetScript('OnTooltipSetItem', OnTooltipSetItem) local PopupDisplayed = false YssBossLoot.QuerryStopped = nil StaticPopupDialogs["YssBossLoot_UnsafeQuery_DIALOG"] = { text = L["UNSAVE_QUERY_MSG"], button1 = YES, button2 = NO, OnAccept = function (self) YssBossLoot.db.global.badLogout = nil QueryNextItem() clicked = true end, OnCancel = function (self, data, reason) if reason == "clicked" then YssBossLoot.QuerryStopped = true end end, OnHide = function() if YssBossLoot.db.global.badLogout then if not YssBossLoot.QuerryStopped then PopupDisplayed = false end YssBossLoot:UpdateLoot(0) end end, timeout = 0, hideOnEscape = 1, noCancelOnEscape = 1, whileDead = 1, } function YssBossLoot:QueryItemInfo(item) if GetItemInfo(item) then -- do a preliminary check if we already know the item return nil end for i, listitem in ipairs(itemlist) do -- check if this item is already in our list if item == listitem then return nil end end itemlist[#itemlist+1] = item if not query_item then if self.db.global.badLogout and time() - self.db.global.badLogout < 900 then if YssBossLoot.QuerryStopped then YssBossLoot:UpdateLoot(0) elseif not PopupDisplayed then PopupDisplayed = true local popup = StaticPopup_Show("YssBossLoot_UnsafeQuery_DIALOG") popup:SetFrameStrata("TOOLTIP") end else self.db.global.badLogout = nil QueryNextItem() end end end function YssBossLoot:CancelAllQueries() wipe(itemlist) query_item = nil if YssBossLoot.queries then wipe(YssBossLoot.queries) end animationGroup:Stop() end local logoutFunctions = { ["Logout"] = true, ["Quit"] = true, ["ForceQuit"] = true, ["ReloadUI"] = true, } local cancelLogoutFunctions = { ["CancelLogout"] = true, } local function logoutHook() YssBossLoot.isValidLogout = true end local function logoutHook_cancel() YssBossLoot.isValidLogout = nil end local function consoleHook(func, ...) for f in pairs(logoutFunctions) do if string.lower(f) == string.lower(func) then return logoutHook() end end for f in pairs(cancelLogoutFunctions) do if string.lower(f) == string.lower(func) then return logoutHook_cancel() end end end -- Setup our Logout Hooks hooksecurefunc("ConsoleExec", consoleHook) for func in pairs(logoutFunctions) do hooksecurefunc(func, logoutHook) end for func in pairs(cancelLogoutFunctions) do hooksecurefunc(func, logoutHook_cancel) end function YssBossLoot:PLAYER_LOGOUT() if not self.isValidLogout and query_item then self.db.global.badLogout = time() elseif self.db.global.badLogout and time() - self.db.global.badLogout > 900 then self.db.global.badLogout = nil end end YssBossLoot.frame:RegisterEvent("PLAYER_LOGOUT") --[[ dc test function (this will DC the client) --/script YssBossLootTest() function YssBossLootTest() animation:SetDuration(.1) for i=1,100 do YssBossLoot:QueryItemInfo(i) end end ]] every item is requested sequentially (it waits for data before it moves on to the next one) In The OnTooltipSetItem() function it calls YssBossLoot:UpdateLoot(#itemlist, query_item) with the item that was found and how many items remain in the queue function QueryNextItem does the same thing if for some reason we already know the item (before we request if from the server) all the other stuff is there to ensure that we do not query the server too fast and get disconnected (can easily happen) Last edited by yssaril : 07-20-10 at 05:43 PM. |
|
07-20-10, 06:05 PM | #3 |
07-20-10, 06:25 PM | #4 |
stays hidden
|
|
WoWInterface » Developer Discussions » General Authoring Discussion » Forced Item Server Query |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|