Jump to content
McKay Development

Crafting problems


Recommended Posts

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)
Link to comment
Share on other sites

  1. 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.
  2. You can't pass an object to craft, it needs to be an item ID.
  3. 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);

Link to comment
Share on other sites

 

  1. 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.
  2. You can't pass an object to craft, it needs to be an item ID.
  3. 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.")
			}
Link to comment
Share on other sites

 

  1. 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")
			}
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 by TextDynasty
Link to comment
Share on other sites

  1. 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 by TextDynasty
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...