TextDynasty Posted December 18, 2016 Report Posted December 18, 2016 Hi.I used the node tf2 for crafting metal, but i found out some problems in my coding that it didn't work. manager.loadInventory(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; } console.log(colors.bold.green.bgYellow("Backpack has " + inventory.length + " items")); var key = inventory.filter(function (item) { return item.name == 'Mann Co. Supply Crate Key' }); var ref = inventory.filter(function (item) { return item.name == 'Refined Metal' }); var rec = inventory.filter(function (item) { return item.name == 'Reclaimed Metal' }); var scrap = inventory.filter(function (item) { return item.name == 'Scrap Metal' }); var tf2 = new TeamFortress2(user); if (scrap.length < 3) { console.log("Crafting more scrap...") tf2.craft(rec) //craft a reclaimed metal when there are not enough scrap } }); Error: node_modules\bytebuffer\dist\ByteBufferNB.js:1067 throw TypeError("Illegal value: "+value+" (not an integer or Long)"); ^ TypeError: Illegal value: [object Object] (not an integer or Long) at TypeError (native) Quote
Dr. McKay Posted December 18, 2016 Report Posted December 18, 2016 You need to be connected to the TF2 GC in order to craft. This means that you can't simply construct a new TeamFortress2 object whenever you want to craft something; you need to create one global one so it can remain connected. You can't pass an object to craft, it needs to be an item ID. rec is an array of objects. If you want to craft a single reclaimed metal into scrap, then you need to extract a single one (say, element #0) and put it in an array by itself.So in order to craft one reclaimed into scrap, you want to do tf2.craft(rec[0].id); Quote
TextDynasty Posted December 18, 2016 Author Report Posted December 18, 2016 You need to be connected to the TF2 GC in order to craft. This means that you can't simply construct a new TeamFortress2 object whenever you want to craft something; you need to create one global one so it can remain connected. You can't pass an object to craft, it needs to be an item ID. rec is an array of objects. If you want to craft a single reclaimed metal into scrap, then you need to extract a single one (say, element #0) and put it in an array by itself.So in order to craft one reclaimed into scrap, you want to do tf2.craft(rec[0].id); Thanks for the answer. The errors are gone, but it didn't craft any metal out... var tf2 = new TeamFortress2(user); if (scrap.length < 3) { user.gamesPlayed([440]); console.log("Crafting more scrap...") tf2.craft(rec[0].id); console.log("Done.") } Quote
Dr. McKay Posted December 19, 2016 Report Posted December 19, 2016 You need to be connected to the TF2 GC in order to craft. This means that you can't simply construct a new TeamFortress2 object whenever you want to craft something; you need to create one global one so it can remain connected. Quote
TextDynasty Posted December 19, 2016 Author Report Posted December 19, 2016 You need to be connected to the TF2 GC in order to craft. This means that you can't simply construct a new TeamFortress2 object whenever you want to craft something; you need to create one global one so it can remain connected. client.on('loggedOn', function (details) { console.log(timestamp("[hh:mm:ss] Logged into Steam as " + config2.username.green)); client.gamesPlayed([440]); //Connected to TF2 GC? }) if (haveGCSession = true) { var tf2 = new TeamFortress2(user); if (scrap.length < 3) { console.log("Crafting more scrap..."); tf2.craft(rec[0].id); console.log("Done."); }} else { console.log("We didn't connected to TF2 GC") } Quote
Dr. McKay Posted December 19, 2016 Report Posted December 19, 2016 No, that's very wrong. Where you create your client, you need to also create your tf2. Quote
TextDynasty Posted December 19, 2016 Author Report Posted December 19, 2016 No, that's very wrong. Where you create your client, you need to also create your tf2.Do you mean by this? var Winston = require('winston'); // For logging var SteamUser = require('steam-user'); // The heart of the bot. We'll write the soul ourselves. var TradeOfferManager = require('steam-tradeoffer-manager'); // Only required if you're using trade offers var config2 = require('./config2.js'); var fs = require('fs'); // For writing a dope-ass file for TradeOfferManager var SteamTotp = require('steam-totp') var Steamcommunity = require('steamcommunity'); var Steam = require('steam'); var colors = require('colors'); var TeamFortress2 = require('tf2'); var Language = require('./language.js'); var timestamp = require('console-timestamp'); var TeamFortress2 = require('tf2'); var handlers = TeamFortress2.prototype._handlers; var client = new SteamUser(); var tf2 = new TeamFortress2(client); //So i created tf2 here? client.on('loggedOn', function (details) { console.log(timestamp("[hh:mm:ss] Logged into Steam as " + config2.username.green)); client.gamesPlayed([440]); //Connected to TF2 GC? }); if (scrap.length < 3) { console.log("Crafting more scrap..."); tf2.craft(rec[0].id); console.log("Done."); } But it didn't work also Quote
Dr. McKay Posted December 19, 2016 Report Posted December 19, 2016 Yes, that's what you need to do. Quote
TextDynasty Posted December 19, 2016 Author Report Posted December 19, 2016 Yes, that's what you need to do.But it didn't work also. The console said i am connected TF2 GC, but it didn't craft anythings Quote
Dr. McKay Posted December 19, 2016 Report Posted December 19, 2016 You need to pass an array. [rec[0].id] Quote
TextDynasty Posted December 19, 2016 Author Report Posted December 19, 2016 (edited) You need to pass an array. [rec[0].id]Do you mean by replacing the [rec[0].id] by the reclaimed metal asset ID itself? if (scrap.length < 3) { console.log("Crafting more scrap..."); tf2.craft([5345296927]); // The assetID? or what should i put in an array console.log("Done."); } Or this? if (scrap.length < 3) { console.log("Crafting more scrap..."); tf2.craft(rec[0].assetid); console.log("Done."); } Edited December 20, 2016 by TextDynasty Quote
Dr. McKay Posted December 20, 2016 Report Posted December 20, 2016 Neither. Just wrap rec[0].id in brackets. Quote
TextDynasty Posted December 20, 2016 Author Report Posted December 20, 2016 (edited) Neither. Just wrap rec[0].id in brackets.Do you mean by this? if (scrap.length < 3) { console.log("Crafting more scrap..."); tf2.craft[rec[0].id]; console.log("Done."); }This doesn't work too Edited December 21, 2016 by TextDynasty Quote
TextDynasty Posted December 21, 2016 Author Report Posted December 21, 2016 Neither. Just wrap rec[0].id in brackets. tf2.craft[rec[0].id]; This doesn't work too... Quote
TextDynasty Posted December 22, 2016 Author Report Posted December 22, 2016 (edited) rec is an array of objects. If you want to craft a single reclaimed metal into scrap, then you need to extract a single one (say, element #0) and put it in an array by itself.So in order to craft one reclaimed into scrap, you want to do tf2.craft(rec[0].id); Sorry. What do you mean by element #0? Edited December 22, 2016 by TextDynasty Quote
TextDynasty Posted December 22, 2016 Author Report Posted December 22, 2016 (edited) Neither. Just wrap rec[0].id in brackets.The assetID works fine but it didn't smelt any metal. Maybe we need a recipe or something? Or my crafting script placed in the wrong place? Edited December 22, 2016 by TextDynasty Quote
Recommended Posts
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.