WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   How to hook C_AuctionHouse.PostItem? (https://www.wowinterface.com/forums/showthread.php?t=57790)

Xruptor 01-25-20 08:49 AM

How to hook C_AuctionHouse.PostItem?
 
I have tried several methods to hook into C_AuctionHouse.PostItem. I want to fire off an event and function when this function is used. However, I don't want to indirectly taint the above function.

Code:

oldFunction = C_AuctionHouse.PostItem
C_AuctionHouse.PostItem = function newFunction() end

I don't want to use code above. That is just insecure and will cause taint issues.

I've used the following code but it does not track whether an item is posted or failed from being posted. It just triggers C_AuctionHouse.PostItem.
Code:

AuctionHouseFrame.CommoditiesSellFrame.PostButton:HookScript("OnClick", function () print('test') end)
I've tried the following.

Code:

hooksecurefunc(C_AuctionHouse, "PostItem", function() print('test') end)
Although it does not cause an error and does hook the function, the hook never properly fires off and I never see the test print. Mind you this is just an example.

Code:

hooksecurefunc(AuctionHouseFrame.CommoditiesSellFrame, "PostItem", function(self)
  print("CommoditiesSellFrame",self:CanPostItem())
end)

I've tried the above code and although it DOES hook properly and fire off when an item is posted. It never registers the item properly in the hook return and thus CanPostItem() is always false.

Here is the global Blizzard code dump I use.
(https://github.com/Gethe/wow-ui-sour...mSellFrame.lua)

There seems to be several mixins that use C_AuctionHouse.PostItem. That is why I just want to hook the parent C_AuctionHouse.PostItem function.

NOTE: I want to point out that the event "OWNED_AUCTIONS_UPDATED" does not fire when using the Sell Frame or Sell Tab on the Auction House. When an item is posted that event is never triggered for some reason. The only other event that seems to fire is "COMMODITY_SEARCH_RESULTS_UPDATED" but it's very unreliable.

So what would be the appropriate way to hook into C_AuctionHouse.PostItem so I can track when items are posted? Is there a better way with the new Auction House code?

SDPhantom 01-26-20 09:23 AM

I don't know the difference yet, but some items use C_AuctionHouse.PostItem() and others use C_AuctionHouse.PostCommodity(). The frame template changes when you select an item to post.

Xruptor 01-26-20 10:39 AM

Quote:

Originally Posted by SDPhantom (Post 335030)
I don't know the difference yet, but some items use C_AuctionHouse.PostItem() and others use C_AuctionHouse.PostCommodity(). The frame template changes when you select an item to post.

Another issue is that C_AuctionHouse.GetNumOwnedAuctions() and C_AuctionHouse.GetOwnedAuctionInfo() does not get updated when the user is on the sell screen. That means you have to forcefully request the update from the server. Otherwise, if you do a scan of the auctions using C_AuctionHouse.GetOwnedAuctionInfo() after a user sells an item, it will be inaccurate and not represent the newly updated number. The only way to update this is the user switches to the Auction tab or you force a query update using C_AuctionHouse.QueryOwnedAuctions(). This is rubbish and the C_AuctionHouse.GetNumOwnedAuctions() should be updated when a user sells something. Huge oversight by Blizzard here.

Oh I would like to point out that requesting a query update using C_AuctionHouse.QueryOwnedAuctions() while a user is on the Sell screen causes a bug. This bug prevents the user from properly selling Stacked items. It's one big mess with this new Auction House.

Xruptor 10-25-20 06:34 AM

Original Post: https://us.forums.blizzard.com/en/wo...pdating/424237

Small update it appears this issue has been fixed. I've been updating my code and have been noticing the servers returns are now properly being updated.

It appears both C_AuctionHouse.GetNumOwnedAuctions() and C_AuctionHouse.GetOwnedAuctionInfo() now are updated properly when a user posts an item on the Sell panel of the Auction House.

The bug used to not update C_AuctionHouse.GetNumOwnedAuctions() and C_AuctionHouse.GetOwnedAuctionInfo() accordingly when a user placed an item up for sale. This doesn't seem to be the case anymore. Which was useless as the user had just recently put an item up for sale. Which meant the data you got back from C_AuctionHouse.GetOwnedAuctionInfo() was outdated and incorrect.


In addition use the following to check for any updates.

C_AuctionHouse.IsThrottledMessageSystemReady() to make sure the server is ready

Use AUCTION_HOUSE_AUCTION_CREATED to check when a user posts an item.


All times are GMT -6. The time now is 09:32 PM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2021 MMOUI