TextDynasty Posted October 9, 2016 Report Posted October 9, 2016 My bot now only accept donation. Anyone know how to script it to make it accept key trades and count items? Quote
adma Posted October 9, 2016 Report Posted October 9, 2016 manager.on("newOffer", function(offer) { var onlyKeys = (offer.itemsToReceive.every(function(item) { return item.name == "Mann Co. Supply Crate Key"; })); if (onlyKeys) { keyAmount = offer.itemsToReceive.length console.log("Received trade offer containing " + keyAmount + " keys, accepting"); 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); }); } } TextDynasty 1 Quote
TextDynasty Posted October 9, 2016 Author Report Posted October 9, 2016 (edited) manager.on("newOffer", function(offer) { var onlyKeys = (offer.itemsToReceive.every(function(item) { return item.name == "Mann Co. Supply Crate Key"; })); if (onlyKeys) { keyAmount = offer.itemsToReceive.length console.log("Received trade offer containing " + keyAmount + " keys, accepting"); 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); }); }} Thanks for the reply but may I know to how to count ref before accepting the offer? For example, the bot will buy keys for 22 ref each? Thanks. Edited October 9, 2016 by TextDynasty Quote
TextDynasty Posted October 10, 2016 Author Report Posted October 10, 2016 (edited) i tried something like this but it doesn't accept my offer. any ideas? 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); }); } }) }); Edited October 10, 2016 by TextDynasty Quote
TextDynasty Posted October 10, 2016 Author Report Posted October 10, 2016 Thanks very much. I found where is my problem. Thanks adma. : ) Have a nice day 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.