Jump to content
McKay Development

How do I add a custom amount of items to a tradeoffer?


Recommended Posts

This isn't really the place to ask JavaScript questions. Stack Overflow is a better place for that. But, here's an example that will add 5 keys:

manager.loadInventory(440, 2, true, (err, inventory) {
	if (err) {
		console.log(err);
		return;
	}
	
	let offer = manager.createOffer(recipient);
	
	// filter inventory to Mann Co. Supply Crate Keys
	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
	let keys = inventory.filter(item => item.market_name == 'Mann Co. Supply Crate Key');
	
	// get only the first 5
	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
	let fiveKeys = keys.slice(0, 5);
	
	offer.addMyItems(fiveKeys);
	offer.send((err, status) => {
		// ...
	});
});

 

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

×
×
  • Create New...