theFarmer Posted December 19, 2023 Report Posted December 19, 2023 Hi all! I am able to generate trades from my "bot" account using `offer.addMyItems(items)` as long as there aren't more than 1 of each item. The moment I trie to add a second item I face issues. I am combining and updating the amount. Here are two console logs: [[[allAssetIds]]] [ '4472701497518213337', '4472701497518213337', '4472701497518213337', '4472701497518213337', '4472701497519256933' ] [[[FORMATEED TEMS]]] [ { appid: 252490, contextid: '2', assetid: '4472701497518213337', amount: 4 }, { appid: 252490, contextid: '2', assetid: '4472701497519256933', amount: 1 } ] The first is the raw items I need to add, and the second is my "formatted" items. However, I get the "Error: There was an error sending your trade offer. Please try again later. (26)" error. It only happens if there is more than 1 of an item, so I think I'm doing something wrong rather than something wrong with the library. Thanks so much! Quote
Dr. McKay Posted December 19, 2023 Report Posted December 19, 2023 What's generating "allAssetIds"? You should never see the same ID more than once. Quote
theFarmer Posted December 19, 2023 Author Report Posted December 19, 2023 (edited) allAssetIDs is just an external array of "owed items" that I loop through to construct the formatted array. If select the same skin twice, I just update the amount to 2 (or whatever number is needed) Edited December 19, 2023 by theFarmer Quote
theFarmer Posted December 19, 2023 Author Report Posted December 19, 2023 I am just noting my progress. It seems that the assetid is not unique to the item, even though I assumed it was. Searching for the name, I was able to find that the amount of items exists, just that each one's assetid was different. So, I will try to take my requested items and match them against the inventory using the market_hash_name instead. I will post back with the outcome on this. Yep! That fixed it. Maybe a better way but my solution looks something like: function prepareTrade(combinedItems, inventory) { let allAssetIds = []; combinedItems.forEach(item => { // Find the index of the item in inventory that matches the current item const foundIndex = inventory.findIndex(invItem => invItem.market_hash_name === item.markethashname); if (foundIndex !== -1) { // If the item is found, push its asset id and remove it from the inventory allAssetIds.push(inventory[foundIndex].assetid); inventory.splice(foundIndex, 1); } }); return allAssetIds; } 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.