Jump to content
McKay Development

Recommended Posts

Posted


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);
});
}
}

 

Posted (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 by TextDynasty
Posted (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 by TextDynasty

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...