Jump to content
McKay Development
orcnaydn

How to limit buy badge per game?

Recommended Posts

I want to someone type my bot !selltf, his sell max 15 sets per game how can i do that?

My Code;

 

Inventory.prototype.getCustomerSets = function(ignore, sid64, callback, permit){
	let self=this;
	this.community.getUserInventoryContents(sid64, 753, 6, true, (err, items) => {
			if(err){
				callback(err); 
			}
			else {
				
				items = items.filter(item => {
					if(item.getTag("item_class").internal_name == "item_class_2" && item.getTag("cardborder").internal_name == "cardborder_0"){ 
						return item;
					}
				});
				
				let customer_sets=[],
					customer_cards={};
				
				items.forEach( card => {
					const appid=card.market_hash_name.split("-")[0];
					if(!customer_cards[appid]){customer_cards[appid]={};}
					if(!customer_cards[appid][card.market_hash_name]){customer_cards[appid][card.market_hash_name]=[];}
					customer_cards[appid][card.market_hash_name].push(card);
				});

				for(let appid in customer_cards){
					if(self.card_db[appid]){
						if(Object.keys(customer_cards[appid]).length == self.card_db[appid]){
							
							let customerHave = Math.min.apply( Math, values(customer_cards[appid]).map( card => card.length ) ),
								botHave = self.AvailableSets[appid] ? self.AvailableSets[appid].length : 0,
								limit = permit ? (self.maxStock+permit) : self.maxStock,
								falt = limit-botHave;
							
							customerHave = !ignore ? ( (falt > 0) ? ( Math.min( ...[ falt, customerHave ]  ) ) : 0 ) : customerHave;
							
							for (let i=0;i<customerHave;i++) {
								let currentCustomerSet=[]
								for(let card in customer_cards[appid]){
									currentCustomerSet.push(customer_cards[appid][card][i]);
								}
								customer_sets.push(currentCustomerSet);
							}
						}
					} else {
						self.getAppIdCount(appid);
					}					
				}
				callback(null, customer_sets);
			}
		});
}

Share this post


Link to post
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...

×
×
  • Create New...