View Full Version : [SOLVED] Confirmation box OnBuyItemFromVendor

07-30-2014, 03:33 PM
Hello there.

I was wondering how would I go about implementing a confirmation box that pops up when the player right clicks a vendor item? This already happens for items with extended cost (I'm guessing the client automatically asks for confirmation for those items, even before sending CMSG_BUY_ITEM_IN_SLOT to the server). However, I would like to make this happen for normal cost items (bought with gold).

I'm thinking I could modify void Player::BuyItemFromVendorSlot(...), which gets called when handling CMSG_BUY_ITEM_IN_SLOT, but if the NPC is a vendor and the context is not gossip scripting, then how can I use PlayerTalkClass() ?

Any help is appreciated, thanks. Sorry if I should have posted in the support section.

07-30-2014, 11:40 PM
It was indeed in the incorrect section, moved to the correct one.

08-01-2014, 12:31 PM
So basically nobody has any clue on how to make the client display a confirmation box and then get the answer (Yes/No) ?

08-02-2014, 10:09 AM
So basically nobody has any clue on how to make the client display a confirmation box and then get the answer (Yes/No) ?

It is not possible without client editing.
One hack is to use gossip window that has a single option that is auto clicked. But I dont think that exactly applies to this situation as a solution.

08-02-2014, 02:40 PM
Might not be the solution but it's definitely a good workaround. I'll update the post with the results (provided that my code compiles lol)

08-04-2014, 09:52 PM
Okay so this is what I have so far. It *works* decently. Im more of a webdev so my C++ coding style might be bad idk please dont hate xD.

I managed to force the client auto-click that single option so confirmbox automagically pops up but what I couldn't keep track of was the link between what the player (buyer), what he wants to buy (item) and whether he confirms or not. So I added a new public property to the World class (an std::map that links player's guid to item's entryid. Then in OnGossipSelect I retrieve the item's entryid and give it to the player (based on his guid).

World.h modifications - http://pastebin.com/ySiD3Z5i
Player.cpp modifications - http://pastebin.com/DXFvwGnf
Vendor script - http://pastebin.com/DEVuguVE

Oh and I also added this in SharedDefines.h (because I couldn't figure out how to use the already existing codes, they are defined as uint32 hex and I just get mindfucked when I see hex)

const std::string ItemQualityColorsString[MAX_ITEM_QUALITY] =
"ff9d9d9d", //grey
"ffffffff", //normal white
"ff1eff00", //green
"ff0070dd", //rare
"ffa335ee", //epic
"ffff8000", //legendary
"ffe6cc80", //heirloom

So now my only problem is that client won't let vendor/gossip windows to show up at the same time. When you try to buy something, the vendor window closes and the confirmation pops up. If you accept, the window opens again (Im calling OnGossipHello in OnGossipSelect) but if you click NO then it just disappears but no vendor windows shows up, it just freezes like that and you have to get away from the vendor to make it completely close ...

If you have anymore tips or anyone else has please share. Thanks a lot