Crptkc Posted December 1, 2019 Report Posted December 1, 2019 in function process(Offer) { I wanted to add stock limit and current stock to my steam trading bot but I lack the knowledge. Simply I want my bot to be able to stop accept trade offer after current stock exceed stock limit, how do I do so.Bot.txt Help would be gladly appreciated, thank you. Quote
vrtgn Posted December 4, 2019 Report Posted December 4, 2019 (edited) How and where are your prices/items that you are buying or selling stored? If there in a JSON file, I would add a `maxStock` and `currentStock` in the file, so it would look something like this: "Team Captain": { "buy": ... ... "maxStock": 3, "currentStock" 1 } Then, in your process function: let amountInTrade = {} for (var i = 0; i < theirItemsNames.length; i++) { amountInTrade[theirItemsNames[i]].amount = (amountInTrade[theirItemsNames[i]] ? amountInTrade[theirItemsNames[i]] + 1 : 1) } ... if (prices[itemName].currentStock + amountInTrade[itemName] <= prices[itemName].maxStock) { // if the amount they are giving plus how much we have is smaller than or equal to maxStock // accept the offer } else { // decline } Edited December 4, 2019 by vrtgn 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.