Jump to content
McKay Development

Recommended Posts

Posted
[ EconItem {
    appid: 730,
    contextid: '2',
    assetid: '7584018068',
    classid: '926978479',
    instanceid: '0',
    amount: 1,
    missing: false,
    icon_url: '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsUFJ5KBFZv668FFAuhqSaKWtEu43mxtbbk6b1a77Twm4Iu8Yl3bCU9Imii1Xt80M5MmD7JZjVLFH-6VnQJQ',
    icon_url_large: '',
    icon_drag_url: '',
    name: 'Chroma 2 Case',
    market_hash_name: 'Chroma 2 Case',
    market_name: 'Chroma 2 Case',
    name_color: 'D2D2D2',
    background_color: '',
    type: 'Base Grade Container',
    tradable: true,
    marketable: true,
    commodity: true,
    market_tradable_restriction: 7,
    fraudwarnings: [],
    descriptions:
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ],
    owner_descriptions: [],
    tags: [ [Object], [Object], [Object], [Object] ],
    id: '7584018068',
    actions: [],
    owner_actions: [],
    market_marketable_restriction: 0 },
  EconItem {
    appid: 730,
    contextid: '2',
    assetid: '7582569339',
    classid: '1690096482',
    instanceid: '0',
    amount: 1,
    missing: false,
    icon_url: '-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXU5A1PIYQNqhpOSV-fRPasw8rsUFJ5KBFZv668FFYynaSdJGhE74y0wNWIw_OlNuvXkDpSuZQmi--SrN-h3gey-Uo6YWmlIoCLMlhplhFFvwI',
    icon_url_large: '',
    icon_drag_url: '',
    name: 'Chroma 3 Case',
    market_hash_name: 'Chroma 3 Case',
    market_name: 'Chroma 3 Case',
    name_color: 'D2D2D2',
    background_color: '',
    type: 'Base Grade Container',
    tradable: true,
    marketable: true,
    commodity: true,
    market_tradable_restriction: 7,
    fraudwarnings: [],
    descriptions:
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ],
    owner_descriptions: [],
    tags: [ [Object], [Object], [Object], [Object] ],
    id: '7582569339',
    actions: [],
    owner_actions: [],
    market_marketable_restriction: 0 } ]

It outputs this.

And I wanna get both names,
and but them into two variables.
 
CASE1 = CASE1 NAME
CASE2 =  CASE2 NAME
Posted (edited)

If you want to get the market hash names of each item you're giving, you would probably use forEach or a for loop to cycle through the itemsToGive array ...
e.g

manager.on('newOffer', function(offer) {
	offer.itemsToGive.forEach(function(item) {
		console.log("Item to give : " + item.market_hash_name); // Items to give: Chroma 2 Case
	});
});

a for ... of loop (edited from for..in loop)

manager.on('newOffer', function(offer) {
	for (var item of offer.itemsToGive) {
		console.log("Items to give : " + item.market_hash_name); // Items to give: Chroma 2 Case
	}
});

a regular for loop

manager.on('newOffer', function(offer) {
	for (var i = 0; i < offer.itemsToGive.length; i++) {
		console.log("Items to give #" + i + " : " + offer.itemsToGive[i].market_hash_name); // Items to give #1 : Chroma 2 Case
	}
});

Same deal will apply for itemsToReceive ... or any other array you wanted to cycle through
 
read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration

Edited by adma

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