Jump to content
McKay Development

Recommended Posts

Posted (edited)
manager.on("newOffer", function(offer) {
	console.log("Incoming offer from " + offer.partner.toString());
	
	//Declining all Trade Holds
	offer.getUserDetails(function(err, me, them) {	
	if (them) {
		if (them.escrowDays > 0) {
		offer.decline();
		console.log("They have trade holds. Declining.");
		client.chatMessage(admin, "User sent a offer with trade hold. Declined.")
		client.addFriend(user);
		setTimeout(function() {client.chatMessage(user, "Sorry. We don't accept offer with trade hold.")}, 10000);
	}}
});
	
	var Rkey = 0
	var Gkey = 0
	var Gmetal = 0
	var Rmetal = 0
	
	var user = offer.partner.getSteam3RenderedID()
	var admin = "76561198302774490"
	
	offer.itemsToReceive.forEach(function(item) {
		if (item.name == "Mann Co. Supply Crate Key"){
			return Rkey++
		}
		else if (item.name == "Refined Metal"){
			return Rmetal += 9
		}
		else if (item.name == "Reclaimed Metal"){
			return Rmetal += 3
		}
		else if (item.name == "Scrap Metal"){
			return Rmetal++
		}}
	);
	
	offer.itemsToGive.forEach(function(item) {
		if (item.name == "Mann Co. Supply Crate Key"){
			return Gkey++
		}
		else if (item.name == "Refined Metal"){
			return Gmetal += 9
		}
		else if (item.name == "Reclaimed Metal"){
			return Gmetal += 3
		}
		else if (item.name == "Scrap Metal"){
			return Gmetal++
		}
	});
	
	var onlyGKeys = (offer.itemsToGive.every(function(item) {
		return item.name == "Mann Co. Supply Crate Key";
	}));
	
	var onlyRKeys = (offer.itemsToReceive.every(function(item) {
		return item.name == "Mann Co. Supply Crate Key";
	}));
		
	//sell key
	if (onlyGKeys) {
		if (Rmetal === Gkey * sellkeyprice) {
		offer.accept(function(err) {
		if (err) 
			console.log(err);
		else 
			console.log("Sold " + Gkey + " Keys.");
			console.log("Amount Correct! Accepting the trade offer.");
			if (Gkey > 0) {
			client.chatMessage(admin, "Sold " + Gkey + " Mann Co. Supply Keys.");
			}
			setTimeout(function() {client.chatMessage(user, "Thanks for using. http://steamcommunity.com/id/111111111")}, 5000);
		});
	}
	else {
		offer.decline(function(err) {
			if (err)
				console.log(err);
				else 
					console.log("Trade offer not validated. Declining");
					client.chatMessage(admin, "They are buying it for " + Rmetal + " Scrap Metal.");
					client.addFriend(user);
					setTimeout(function() {client.chatMessage(user, "Your offer is incorrect. Please check it again or resent it later.")}, 10000);
		});
	}}
	
	//buy key
	if (onlyRKeys) {
		if (Gmetal === Rkey * buykeyprice) {
		offer.accept(function(err) {
		if (err) 
			console.log(err);
		else 
			console.log("Bought " + Rkey + " Keys.");
			console.log("Amount Correct! Accepting the trade offer.");
			if (Rkey > 0) {
			client.chatMessage(admin, "Bought " + Rkey + " Mann Co. Supply Keys.");
			}
			setTimeout(function() {client.chatMessage(user, "Thanks for using. http://steamcommunity.com/id/11111111")}, 5000);
		});
	}
	
	else {
		offer.decline(function(err) {
			if (err) console.log(err);
				else 
					console.log("Trade offer not validated. Declining");
					client.chatMessage(admin, "They are selling it for " + Gmetal + " Scrap Metal.");
					client.addFriend(user);
					setTimeout(function() {client.chatMessage(user, "Your offer is incorrect. Please check it again or resent it later.")}, 15000);
		});
	}}
	
	//other offers will be declined
	else {
		offer.decline(function(err) {
			if (err) 
				console.log(err);
				else 
					console.log("Trade offer not validated. Declining");
					client.chatMessage(admin, "User provided a wrong offer. Declined.");
					client.addFriend(user);
					setTimeout(function() {client.chatMessage(user, "Your offer is incorrect. Please check it again or resent it later.")}, 15000);
		});
	}});

Error:

Trade offer not validated. Declining
{ Error: There was an error accepting this trade offer.  Please try again later. (11)
    at Object.exports.makeAnError (C:\Users\Admin\Desktop\Ashley\node_modules\steam-tradeoffer-manager\lib\helpers.js:17:12)
    at SteamCommunity.manager._community.httpRequestPost (C:\Users\Admin\Desktop\Ashley\node_modules\steam-tradeoffer-manager\lib\classes\TradeOffer.js:485:13)
    at Request._callback (C:\Users\Admin\Desktop\Ashley\node_modules\steamcommunity\components\http.js:67:15)
    at Request.self.callback (C:\Users\Admin\Desktop\Ashley\node_modules\request\request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (C:\Users\Admin\Desktop\Ashley\node_modules\request\request.js:1163:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (C:\Users\Admin\Desktop\Ashley\node_modules\request\request.js:1085:12) eresult: 11 }
Amount Correct! Accepting the trade offer.

Anyone can help?

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...