Vanilla Posted July 22, 2017 Report Posted July 22, 2017 (edited) Hello, how did I counter an incoming trade offer?I know that I need to use "offer.counter()", but I don't know how to use it. I got this following code to counter an offer, but it will show an error "Cannot add item to an already-sent offer". manager.on('newOffer', function(offer) { if (offer.partner.getSteamID64() == admin){ //Counter an offer by adding new item offer.counter(); offer.addMyItem({"appid": 753, "contextid": 6, "assetid": "5222324266"}); //error here offer.send(function(err, status){ if (err){ console.log("Error: "+err); } console.log("Status: "+status) }); } } Can anyone show the correct code please? I would really appreciate it.Thanks Edited July 22, 2017 by Vanilla Quote
Dr. McKay Posted July 22, 2017 Report Posted July 22, 2017 offer.counter() returns a new TradeOffer object. You need to perform your changes on that TradeOffer that it returns. Quote
Vanilla Posted July 23, 2017 Author Report Posted July 23, 2017 (edited) offer.counter() returns a new TradeOffer object. You need to perform your changes on that TradeOffer that it returns.So, I need to use offer.counter() to get tradeoffer object, make change on that, and send new trade offer? Edited July 23, 2017 by Vanilla Quote
Vanilla Posted July 23, 2017 Author Report Posted July 23, 2017 (edited) Correct. Thanks, just successfully make a counter offer.I only need to add "counter()" everytime I want to counter an offer. This is the working counter offer code (for those who got same problem) manager.on('newOffer', function(offer) { if (offer.partner.getSteamID64() == admin){ //Counter an offer offer.counter().addMyItem({"appid": 753, "contextid": 6, "assetid": "5222324266"}); offer.counter().send(function(err, status){ if (err){ console.log("Error: "+err); } console.log("Status: "+status) }); //confirmation } } Edited July 23, 2017 by Vanilla Quote
Dr. McKay Posted July 23, 2017 Report Posted July 23, 2017 No, that's wrong. Don't call counter() more than once. Call it once and store the result in a variable. Quote
Vanilla Posted July 23, 2017 Author Report Posted July 23, 2017 No, that's wrong. Don't call counter() more than once. Call it once and store the result in a variable. Lol, so that's why I'm unable to add new item. Now works like a charm, thanks. manager.on('newOffer', function(offer) { if (offer.partner.getSteamID64() == admin){ //Counter an offer by adding new item var counteroffer = offer.counter(); counteroffer.addMyItem({"appid": 753, "contextid": 6, "assetid": "5222324266"}); counteroffer.send(function(err, status){ if (err){ console.log("Error: "+err); } console.log("Status: "+status) }); //confirmation } } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.