Closed ashley-dv closed 7 years ago
Do you know the correct trade protocol? Your accept packet has the correct boolean array's in it?
Trades are accepted as soon as they are requested
As soon as the other player accepts the trade, I want the bot to accept the trade as well. I'm not sure how to go about this, though.
void Client::onTradeAccepted(Packet p)
{
// This is stuff that doesn't work, at least I tried
std::vector
How am I to go about accepting the offer?
Yeah your packet data is wrong. Go check some of the k-relay traderbots on mpgh to see how the accept packet is formatted.
I also cant figure out why you created a PlayerText
packet and send it, you didnt even fill in any text for it...
The PlayerText thing is to PM me when a trade is completed, I removed the line containing the text because it contained my IGN.
Still can't figure out how to do this. I basically copied this code from PixelZerg's bot.
PlayerText ptext;
std::vector
DebugHelper::print("S -> C: Trade has been accepted");
ptext.text = "/tell [censored] Trade attempted";
accept.yourOffer = changed.offer;
accept.myOffer = gettosel;
packetio.sendPacket(ptext.write());
packetio.sendPacket(accept.write());
[This is my current onTradeAccepted. And formatting, again.]
I am simply too dumb to understand how to do this. This current code gives me the error 'Expression: vector
Yeah i have no idea what you are trying to do there in creating the vector. A vector is like an array, except you dont have a preset size, so you cant just jump to the 4th element of nothing.
I honestly have 0 idea what you are doing in your code you just posted, it would help if you formatted it so i can read it easier, but it also doesnt make much sense.
If you arent trading anything from your bot, myOffer
has to be 12 "false" elements. You can do something as simple as:
for(int i = 0; i < 12; i++) accept.myOffer.push_back(false);
And thats all you need for the myOffer
bit.
Assuming the changed.offer
value is valid, that should work, but if not just create the yourOffer
vector of 12 bools using "false" for not trading the item and "true" for trading the item.
Sure enough, what you did worked. While TradeChanged has the data for the offer and what is selected (I think, at least), it's only sent in the packet.
changed.offer is just the same as accept.yourOffer. It needs to be manually assigned. Of course, I am an idiot, as displayed, so I'll either never find a way to work around manually assigning accept.yourOffer or it'll take a very long time.
so I'll either never find a way to work around manually assigning accept.yourOffer or it'll take a very long time.
Using the value from the change trade packet will work. But you cant reference it unless you store that value somewhere in the class. Probably the easiest way to do it would be to go to the Client header file and add something like, TradeChanged lastTradeChange;
and then in the handler for TradeChanged just store the packet value this->lastTradeChange = (TradeChanged)p;
. Then finally, in your accept handler you can set the yourOffer
to accept.yourOffer = this->lastTradeChange.offer
;
Doing something like that would work.
Unless you are just saying that you dont know how to assign the acccept.yourOffer
without doing something like accept.yourOffer = change.offer;
...which that is impossible. You will always have to set the values in the packet since they are all blank when you create it.
Closing this issue as it appears to be solved. You can open another issue if you need more assistance.
How do you accept a trade using this bot? I don't need to select anything in the bot's inventory. Every attempt with AcceptTrade packet has resulted in either cancelling the trade instead of accepting or just plain crashing the bot.
Sorry for noob question.