mistathiccums Posted March 12, 2022 Report Posted March 12, 2022 I have the code in this pastebin, (https://pastebin.com/Zzv4Jifv) -> and this adds all the items in my inventory to a trade offer, how could i manipulate this code into adding a certain amount of items? say 5 tf2 keys instead of the entire inventory? I'm new to javascript and don't much knowledge of it. Quote
Dr. McKay Posted March 12, 2022 Report Posted March 12, 2022 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) => { // ... }); }); Quote
mistathiccums Posted March 12, 2022 Author Report Posted March 12, 2022 It worked! Thank you so much. I know that this isn't really where I'm supposed to ask this question, but you were the only person that I thought might know. Have a good rest of your evening! 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.