Saturday, April 14, 2012

How can I get around the "lag" from getting gold in the inventory? (delay?)

[:1]Hello guys!

Sorry about the long title :)





I'm currently creating my very first addOn. It's a simple and smal one that auto-sells all grey items when I talk to a vendor. Now that part works like a charm. However...

I would also like the addOn to writ a msg to the chat that tells the user how much gold he made from the sale.

I've got all that I need for that, but for one thing: some kind of delay.

I'm using GetGold() to get the gold value pre-sale and intend to use the same after the sale has been made. Here is my problem: due to the "lag" that happens between you're selling an item and you actually get the gold in your backpack the parsing is done with the second GetGold() query. In other words I'm always getting 0 as a result. (as the gold hasn't been updated yet)



Could anyone give me a hand with this?

got 2 funcitons atm:

sellTrash() -- it sells the trash! bet you didn't see that one coming!

printProfit() -- that's the one I somehow would like to be delayed (got the math part in this function also) (sellTrash() got the first GetGold(), this one got the second GetGold() )|||Quote:








Could anyone give me a hand with this?




Two mods you might review to see how they do it...

1. Lootfilter, and

2. CTmod, for the money tracking feature.|||also might wanna look at AutoProfit and maybe Postal.|||I've had look at all of the addOns you've suggested, but I couldn't realy get much out off it.

As this is my first addon I'm very new to the whole thing.



So far the addon is handling all the math problems and printouts just fine, the only thing I need is a delay on the second GetGold(). Now it might be a "big no no", but I would be fine with a static 5 sec delay or something. It might not be very smooth, but it should do the trick. Think you could help me out with the code?

I've also come up with a different and perhaps a more smooth solution to this problem, and that would be to some how get the value from the item I'm selling. Is there any WoW function that returns the value you see when you mouseover a stack at the vendor? It have to * with the number of items in the stack ofc.|||I have 3 solutions for you:

1) Go to wowwiki and look up the 'OnUpdate' How-To. You can create timers with this function.

2) Use AceTimer-3.0. There is documentation on the wowace page on how to use this.

3) Read the price of the item from the CHAT_MSG_LOOT event, and add it up.

No comments:

Post a Comment