Jump to content


Photo
Question

How to check if the items received are trading cards ?

node.js node-steam-tradeoffer-manager

Best Answer Dr. McKay , 25 November 2018 - 12:00 AM

Do something like this:

let isEachItemATradingCard = theirItems.every((item) => {
	if (item.appid != 753 || item.contextid != 6) {
		// AppID is not "Steam" or contextid is not "Community"
		return false;
	}
	
	let tag = item.getTag('item_class');
	if (!tag || tag.internal_name != 'item_class_2') {
		// Not a trading card
                // You could also check that tag.localized_tag_name == 'Trading Card' but that would only work for English
		return false;
	}
	
	return true; // all checks passed
});
Go to the full post


  • Please log in to reply
2 replies to this topic

#1 R3v3rso

R3v3rso

    Newbie

  • Member
  • Pip
  • 5 posts
  • LocationValenciennes, France

Posted 21 November 2018 - 12:00 PM

Hello,

I'm currently stuck with something that I assume is very simple, but I can't find any tutorial or help about it anywhere on the internet...

 

I'm currently trying to create a bot that trades random Steam game codes for random steam cards, but my problem right now is that I don't know how to check if all items that the bot will receive are trading cards.

 

I'm aware that this probably is a really easy thing, but I really have no idea where to find my answers :/

 

 

Thanks a lot for reading this, hopefully you can me with that :P

 

This is what I have done so far :

//This is where the pain begins.
function processOffer(offer) {
 if (offer.partner.getSteamID64() === config.ownerID) {
    acceptOffer(offer);
} else if (offer.isGlitched() || offer.state === 11) {
    console.log("Offer was glitched, declining.");
    declineOffer(offer);
} else {
    var theirItems = offer.itemsToReceive
    var ourItems = offer.itemsToGive

}}


manager.on('newOffer', (offer) => {
    console.log("Offer received, processing");
    processOffer(offer);
})}


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,817 posts

Posted 25 November 2018 - 12:00 AM   Best Answer

Do something like this:

let isEachItemATradingCard = theirItems.every((item) => {
	if (item.appid != 753 || item.contextid != 6) {
		// AppID is not "Steam" or contextid is not "Community"
		return false;
	}
	
	let tag = item.getTag('item_class');
	if (!tag || tag.internal_name != 'item_class_2') {
		// Not a trading card
                // You could also check that tag.localized_tag_name == 'Trading Card' but that would only work for English
		return false;
	}
	
	return true; // all checks passed
});

  • R3v3rso likes this

#3 R3v3rso

R3v3rso

    Newbie

  • Member
  • Pip
  • 5 posts
  • LocationValenciennes, France

Posted 25 November 2018 - 04:18 PM

Thank you very much !







Also tagged with one or more of these keywords: Question, node.js, node-steam-tradeoffer-manager

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users