Jump to content
McKay Development

TomYoki

Member
  • Posts

    82
  • Joined

  • Last visited

Community Answers

  1. TomYoki's post in Reload/Recall LoadInventory on errror was marked as the answer   
    function loadinventory(AppID, ContextID) {
    manager.getInventoryContents(AppID, ContextID, true, function(err, inv, curr) { //You were using deprecated method
    if(err) {
    console.log("Error while loading inventory."); //Gotta use proper grammar.
    setTimeout(function(){
    loadInventory(AppID, ContextID);
    }, 1000*60); //Set timeout (as Führer McKay pointed out);
    return;
    }
    //code
    });
    }

    loadinventory(AppID, ContextID);
     
  2. TomYoki's post in Cannot read property 'market_hash_name' of undefined was marked as the answer   
    Honestly, don't comment if you have absolutely no clue what's going on.
     
     
    This should work:
     
    EDIT: You also have 3 other issues with your code that I did not notice at first (as I didn't look at the main code).
    1.) You are using a deprecated method. You want to use https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/TradeOfferManager#getinventorycontentsappid-contextid-tradableonly-callback
    Example: 
    manager.getUserInventoryContents(partner, appid, contextid, true, (err, theirInv) => {...}); 2.)  Line 158 it needs to be either 'var', 'let' or 'const' unless you are wanting to re-define it.
     
    3.)  last issue (that I found) would be on line 163, what you want to do there is change it to 
    var keyToAdd = availableKey[0] //Change it simply to 'availableKey' if you want to add all of the keys found. and from there refer to it as keyToAdd.
     
     
     
    Back to your solution for 'checkAvailableKey' function
    function checkAvailableKey(inventory, acceptedKeyList){ var availableKey = []; //Create an empty array where we can store item data. for(var i=0; inventory.length>i;i++){ //Loop through inventory. if (acceptedKeyList.indexOf(inventory[i].market_hash_name) >= 0){ //Check if there is this item in your array. availableKey.push(inventory[i]); //Push all item info, such as assetid, name, amount etc. } } return availableKey; //return the array with item data. /* P.S: You don't need to make the function ask for the array every time, just add the array with accepted keys in your global scope. However, this is prefered if you have multiple arrays which you want to check. */ }
  3. TomYoki's post in Getting item id was marked as the answer   
    just call 
    manager.getExchangeDetails(); https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/TradeOffer#getexchangedetailsgetdetailsiffailed-callback
  4. TomYoki's post in How to get the traded items ? was marked as the answer   
    offer.itemsToReceive.forEach(function(item) { if (item.appid == "440" && item.market_hash_name == "Scrap Metal") { console.log("It's a bird! It's a plane! IT'S A SCRAP METAL!"); } } ); Something I made you real quick. 
    You can do it the same way for itemsToGive
     
    You can also get some of this info out of it:
    https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItem
  5. TomYoki's post in Automatically accepts all trade offers, but it doesn't have to was marked as the answer   
    https://www.w3schools.com/jsref/jsref_indexof_array.asp
×
×
  • Create New...