Jump to content
McKay Development

Not reading item.tag correctly


jafix

Recommended Posts

manager.on('newOffer', function (offer) {
var onlyCards = (offer.itemsToReceive.every(function(item) {
			return item.tag == "Trading card" && item.tag == "Not Marketable";
			}));
			
			console.log('[OFFER] Checking offer containments');
			if (onlyCards) {
				receiveCardAmount = offer.itemsToReceive.length
				giveCardAmount = offer.itemsToGive.length
				
				if (receiveCardAmount == 2) {
					console.log('[OFFER] Received items = 2');
					
					if (giveCardAmount == 1) {
						
						console.log('[OFFER] Given items = 1');
						
						offer.accept();
						client.chatMessage('76561198259000054', 'Trade offer #' + offer.id + ' from ' + offer.partner.getSteamID64() + ' accepted. 2 new cards in inventory');
						tradelog.info('Trade offer #' + offer.id + ' from ' + offer.partner.getSteamID64() + ' accepted. 2 new cards in inventory')
						console.log('[OFFER] Accepted - contains correct items');
					}
				}
				
			} else {
				offer.decline();
				console.log('[OFFER] Declined - contains non card items or not the correct amount');
				tradelog.info('Offer #' + offer.id + ': Declined - contains non card items')
				}
			}
		});
});

My offer gets declined even though I'm sure I matched everything. I think it's with the tags but it might be a problem with the item amount

Link to comment
Share on other sites

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