Jump to content
McKay Development

Possible to add getInventoryContents into function?


TomYoki

Recommended Posts

Hello, I tried making getInventoryContents into a function so It'd be able to update time to time,

however I get this error:

:384
    manager.getInventoryContents(440, 2, true, function(err, inventory) {
           ^

TypeError: Cannot read property 'getInventoryContents' of undefined

Part of code:

function LoadInventory(manager, callback){
    manager.getInventoryContents(440, 2, true, function(err, inventory) {
            if (err) {
                console.log(err);
                return;
            }

            if (inventory.length == 0) {
                // Inventory empty
                console.log("TF2 inventory is empty");
                return;
            } else {

Edited by TomYoki
Link to comment
Share on other sites

Oh, I forgot to set manager when calling the function.

Now I have new issue tho

\node_modules\steamcommunity\components\users.js:357
                        "uri": "https://steamcommunity.com/inventory/" + userID.getSteamID64() + "/" + appID + "/" + contextID,
                                                                               ^

TypeError: Cannot read property 'getSteamID64' of null

I used to have this before I set SteamID for tradeoffer manager,

and it works fine when I call it from chat command.

However functions don't seem to like it :(

 

Part of code:

function LoadInventory(manager, callback){
    manager.getInventoryContents(440, 2, true, function(err, inventory) {
            if (err) {
                console.log(err);
                return;
            }

            if (inventory.length == 0) {
                // Inventory empty
                console.log("TF2 inventory is empty");
                return;
            } else {

                   //My tids and bits          

            console.log("Found " + inventory.length + " TF2 items");
            }
        });
    setTimeout(LoadInventory, 3600000);
}

LoadInventory(manager);
Link to comment
Share on other sites

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