Jump to content


Photo
Question

How to add only 1 item type to offer

node.js node-steam-tradeoffer-manager

Best Answer Dr. McKay , 24 January 2019 - 05:21 AM

let tag;
if ((tag = item.getTag('item_class')) && tag.internal_name == 'item_class_2') { ... }
Go to the full post


  • Please log in to reply
9 replies to this topic

#1 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 22 January 2019 - 09:49 AM

Say I want to create an offer but need to add just Trading Cards to it, how do I select them?

 

I already know about appid, contextid and "item_class_2" but I need a working example after I loaded my Inventory, which has 4 [Object] inside "tags":

 

  CEconItem {
    appid: 753,
    contextid: '6',
    assetid: '10305554518',
    classid: '1496965455',
    instanceid: '0',
    amount: 1,
    pos: 30,
    id: '10305554518',
    background_color: '',
    icon_url:
     'IzMF03bk9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdA3g5gMEPvUZZEaiHLrVJRsl8vGuCUY7Cjc9ehDNVzDMCeHqtjCQrcex4NM6b8wT1tePGP3j2fSSCJizYG1s1RLtXYTzc9zSjsL-QQj6dE-wkEggGfvQA8GFPPZzbNhM_1YcK_GPhwwp3DhFucMpUdAqp9X0eMLoglXVEd59RmXWjJpDc1F5hYUA8W-2yBLzHbdLzlSYhCxtiGvEYMYOXsXDyuMmmfLGLLIM8gGfI',
    icon_url_large:
     'IzMF03bk9WpSBq-S-ekoE33L-iLqGFHVaU25ZzQNQcXdA3g5gMEPvUZZEaiHLrVJRsl8vGuCUY7Cjc9ehDNVzDMCeHqtjCQrcex4NM6b8wT1tePGP3j2fSSCJizYG1s1RLtXYTzc9zSjsL-QQj6dE-wkEggGfvQA8GFPPZzbNhM_1YcK_GPhwwp3DhFucMpUdAqp9X0eMLoglXVEd59RmXWjJpDc1F5hYUA8W-2yBLzHbdLzlSYhCxtiGvEYMYOXsXDyuMmmfLGLLIM8gGfI',
    descriptions: [ [Object] ],
    tradable: true,
    owner_actions: [ [Object], [Object] ],
    name: 'Santa Claus',
    type: 'Solitaire Christmas. Match 2 Cards Trading Card',
    market_name: 'Santa Claus',
    market_hash_name: '428510-Santa Claus',
    market_fee_app: 428510,
    commodity: true,
    market_tradable_restriction: 7,
    market_marketable_restriction: 7,
    marketable: true,
    tags: [ [Object], [Object], [Object], [Object] ],
    is_currency: false,
    fraudwarnings: [] },
  CEconItem {
 


#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,944 posts

Posted 22 January 2019 - 03:53 PM

CEconItem has a getTag method. Filter your inventory to only items with the tag you're looking for.


  • roughnecks likes this

#3 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 22 January 2019 - 03:56 PM

Thanks Doc, didn't know about getTag, will check that out and let you know later.



#4 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 23 January 2019 - 10:42 AM

So, I get this for tags array (trading card):

 

[17:07:04] [LOG]    [ { internal_name: 'droprate_0',

    name: 'Common',

    category: 'droprate',

    category_name: 'Rarity',

    localized_tag_name: 'Common',

    color: '',

    localized_category_name: 'Rarity' },

  { internal_name: 'app_388390',

    name: '"Glow Ball" - The billiard puzzle game',

    category: 'Game',

    category_name: 'Game',

    localized_tag_name: '"Glow Ball" - The billiard puzzle game',

    color: '',

    localized_category_name: 'Game' },

  { internal_name: 'cardborder_0',

    name: 'Normal',

    category: 'cardborder',

    category_name: 'Card Border',

    localized_tag_name: 'Normal',

    color: '',

    localized_category_name: 'Card Border' },

  { internal_name: 'item_class_2',

    name: 'Trading Card',

    category: 'item_class',

    category_name: 'Item Type',

    localized_tag_name: 'Trading Card',

    color: '',

    localized_category_name: 'Item Type' } ]

 

 

 

And the getTag method is:

getTag(category)
  • category - A string containing the tag's category (the category property of the tag object)

 

So, which category should I look for? I don't see any meaningful one on the array.



#5 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,944 posts

Posted 23 January 2019 - 05:03 PM

item_class



#6 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 24 January 2019 - 05:03 AM

Sorry but every Item has that "item_class" category, so how do I separate Cards from everything else?

 

[16:24:10] [LOG]    [ { internal_name: 'droprate_1',

    name: 'Uncommon',

    category: 'droprate',

    category_name: 'Rarity',

    localized_tag_name: 'Uncommon',

    color: '',

    localized_category_name: 'Rarity' },

  { internal_name: 'app_285840',

    name: 'Enemy Mind',

    category: 'Game',

    category_name: 'Game',

    localized_tag_name: 'Enemy Mind',

    color: '',

    localized_category_name: 'Game' },

  { internal_name: 'item_class_3',

    name: 'Profile Background',

    category: 'item_class',

    category_name: 'Item Type',

    localized_tag_name: 'Profile Background',

    color: '',

    localized_category_name: 'Item Type' } ]



#7 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,944 posts

Posted 24 January 2019 - 05:21 AM   Best Answer

let tag;
if ((tag = item.getTag('item_class')) && tag.internal_name == 'item_class_2') { ... }


#8 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 24 January 2019 - 06:11 AM

I already used that 

tag.internal_name == 'item_class_2'

in another place but now it's different because I'm not getting a tags array when loading my inventory, but 3 or 4 nested objects (like I first posted) and I don't know how to access them.



#9 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,944 posts

Posted 24 January 2019 - 05:14 PM

You are still getting an array. tags: [ [Object], [Object], [Object], [Object] ] is just how console.log represents an array containing 4 objects.


  • roughnecks likes this

#10 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 40 posts

Posted 25 January 2019 - 11:24 AM

Got it to work with some "quirks", so thanks for helping me out so far. Onto the next quest!







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