Jump to content
McKay Development

Recommended Posts

Posted

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.

Posted (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 by vrtgn

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