TextDynasty Posted October 8, 2016 Report Posted October 8, 2016 Hi.I want to know how to count items in trade offer to make trade offer more usefuli've tried this code but it didn't seems working var item_from_me ={ "appid": 440, "contextid": 2, "amount": 1,"assetid": "5148534535", "item.name": "Refined Metal"} var item_from_them ={ "appid": 440, "contextid": 2, "amount": 1,"assetid": "5158673853", "item.name": "Mann Co. Supply Crate Key"}offers.on('newOffer', function (offer) { if (offer > 0) { offers.getOffers({ get_received_offers: 1, active_only: 1, time_historical_cutoff: Math.round(Date.now() / 1000) }, function(error, body) { if(body.response.trade_offers_received) { body.response.trade_offers_received.forEach(function(offer) { if (offer.trade_offer_state == 2) { console.log(offer); console.log('Recieved trade offer: ' + offer.tradeofferid); if (offer.items_to_give === item_from_me * 22 && offer.items_to_recieve === item_from_them) { offers.acceptOffer({tradeOfferId: offer.tradeofferid}); console.log("Offer accepted"); if (offer.steamid_other !== admin) { steam.sendMessage(admin, offer.steamid_other + " just donated!"); } } else { offers.declineOffer({tradeOfferId: offer.tradeofferid}); console.log("Offer declined"); } } }); } }); } Quote
Dr. McKay Posted October 8, 2016 Report Posted October 8, 2016 You're not using steam-tradeoffer-manager. Quote
TextDynasty Posted October 10, 2016 Author Report Posted October 10, 2016 (edited) You're not using steam-tradeoffer-manager. sorry my bad. offers.on('newOffer', function (offer) { manager.on("newOffer", function(offer) { var onlyKeys = (offer.itemsToReceive.every(function(item) { return item.name == "Mann Co. Supply Crate Key"; })); var onlyRef = (offer.itemsToGive.every(function(item) { return item.name == "Refined Metal"; })); if (onlyKeys, onlyRef) { keyAmount = offer.itemsToReceive.length refAmount = offer.itemsToGive.length console.log("Received trade offer containing " + keyAmount + " keys, accepting"); if (keyAmount == refAmount * 21) offer.accept(function(err) { if (err) console.log(err); }); } else { console.log("Trade offer contains non key items. Declining"); offer.decline(function(err) { if (err) console.log(err); }); } }) }); i tried something like this but it doesn't accept my offer. any ideas? Edited October 10, 2016 by TextDynasty 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.