Jump to content


Photo
Question

tf2-node defIndex only returning undifined



Best Answer Dr. McKay , 01 July 2019 - 02:27 PM

As of v3, properties are not converted from snake_case to camelCase. So instead of using defIndex, you need to use def_index.

Go to the full post


  • Please log in to reply
1 reply to this topic

#1 Jyn

Jyn

    Newbie

  • Member
  • Pip
  • 3 posts

Posted 01 July 2019 - 09:02 AM

For whatever reason I cant seem to get any values from defIndex. From the first log each item in my backpack is just being returned as having a defIndex of undefined.
what is annoying too is that tf2.backpack[i].id works fine to get the specific item id's. Code below:



tf2.on('backpackLoaded', function () {
    log("Loaded our backpack.");
    lookforrefined()
});

function lookforrefined() {
  var refcount = 0;
  for (i = 0; i <tf2.backpack.length; i++) { 
    log(tf2.backpack[i].defIndex); // only returning 'undefined'

    if (tf2.backpack[i].defIndex === 5002) {
        refcount++;
        log("foundref");
    }
  }
  log(refcount)
};



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,212 posts

Posted 01 July 2019 - 02:27 PM   Best Answer

As of v3, properties are not converted from snake_case to camelCase. So instead of using defIndex, you need to use def_index.







Also tagged with one or more of these keywords: Question

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users