node-tf2 icon indicating copy to clipboard operation
node-tf2 copied to clipboard

Code example

Open crazydenix opened this issue 10 years ago • 3 comments

Hello. Can you give example code for delete crates? I'm sorry, but I'm newbe to this issue

crazydenix avatar Dec 24 '14 07:12 crazydenix

That's pretty low on my priority list. Just listen for the backpackLoaded event then console.log(tf2.backpack) to see a raw dump of your backpack contents. That should get you started.

DoctorMcKay avatar Dec 25 '14 19:12 DoctorMcKay

I know this is kind of old, but one way to delete all the crates in your inventory is to add this function to your code and call it anywhere (like when you send a message, "!delete" for example).

function deleteCrates() {
    var crates;
    steamTrade.loadInventory(440, 2, function(inv) {
        crates = inventory.filter(function (item) {
            return item.tags.some(function(element, index, array) {
                return element.internal_name == 'Supply Crate';
            });
        });
    });
    if(crates.length > 0) {
        bot.gamesPlayed([440]);
        for(var i = 0; i < crates.length; i++) {
            tf2.deleteItem([crates[i].id]);
        }
    }
};

Where bot is an instance of node-steam, steamTrade is an instance of node-steam-trade, and tf2 is an instance of node-tf2 (this module).

kjsmita6 avatar Jun 24 '15 22:06 kjsmita6

It would be better to use node-tf2's cached backpack.

DoctorMcKay avatar Jun 25 '15 00:06 DoctorMcKay