Kamcio133 Posted March 2, 2017 Report Share Posted March 2, 2017 Hey, guys can u help me? when i add this offer.addMyItem(inventory[0]); that not work /; // Create and send the offer var offer = manager.createOffer("https://steamcommunity.com/tradeoffer/new/?xxxxxxxxxxxxxx"); offer.addMyItems(inventory); offer.addMyItem(inventory[0]); offer.setMessage("Here, have some items!"); offer.send(function(err, status) { if (err) { console.log(err); return; } Quote Link to comment Share on other sites More sharing options...
Enemtia Posted May 7, 2017 Report Share Posted May 7, 2017 Yes. I would like to send 1 item. But it's not working inventory[0]. Can anyone help me? Quote Link to comment Share on other sites More sharing options...
SunriseM Posted May 7, 2017 Report Share Posted May 7, 2017 (edited) First you need to load your inventory. Use method getInventoryContents(appid, contextid, tradableOnly, callback) first and then you can use the inventory callback. Documentation Edited May 7, 2017 by SunriseM Quote Link to comment Share on other sites More sharing options...
Enemtia Posted May 7, 2017 Report Share Posted May 7, 2017 For some reason it is not good either: items.foreEach(function(item){ TypeError: items.forEach is not a function. Quote Link to comment Share on other sites More sharing options...
SunriseM Posted May 8, 2017 Report Share Posted May 8, 2017 For some reason it is not good either: items.foreEach(function(item){ TypeError: items.forEach is not a function. Show all your code please Quote Link to comment Share on other sites More sharing options...
Enemtia Posted May 8, 2017 Report Share Posted May 8, 2017 /** * OFFLOADER * * Once logged in, sends a trade offer containing this account's entire tradable CS:GO inventory. */ var SteamUser = require('steam-user'); var SteamCommunity = require('steamcommunity'); var SteamTotp = require('steam-totp'); var TradeOfferManager = require('steam-tradeoffer-manager'); // use require('steam-tradeoffer-manager') in production var fs = require('fs'); var client = new SteamUser(); var manager = new TradeOfferManager({ "steam": client, // Polling every 30 seconds is fine since we get notifications from Steam "domain": "example.com", // Our domain is example.com "language": "en" // We want English item descriptions }); var community = new SteamCommunity(); // Steam logon options var logOnOptions = { "accountName": "username", "password": "password", "twoFactorCode": SteamTotp.getAuthCode("sharedSecret") }; if (fs.existsSync('polldata.json')) { manager.pollData = JSON.parse(fs.readFileSync('polldata.json')); } client.logOn(logOnOptions); client.on('loggedOn', function() { console.log("Logged into Steam"); }); client.on('webSession', function(sessionID, cookies) { manager.setCookies(cookies, function(err) { if (err) { console.log(err); process.exit(1); // Fatal error since we couldn't get our API key return; } console.log("Got API key: " + manager.apiKey); // Get our inventory manager.getInventoryContents(730, 2, true, function(err, inventory) { if (err) { console.log(err); return; } if (inventory.length == 0) { // Inventory empty console.log("CS:GO inventory is empty"); return; } console.log("Found " + inventory.length + " CS:GO items"); // Create and send the offer var offer = manager.createOffer("https://steamcommunity.com/tradeoffer/new/?partner=12345678&token=xxxxxxxx"); offer.addMyItems(inventory[0]); offer.setMessage("Here, have some items!"); offer.send(function(err, status) { if (err) { console.log(err); return; } if (status == 'pending') { // We need to confirm it console.log(`Offer #${offer.id} sent, but requires confirmation`); community.acceptConfirmationForObject("identitySecret", offer.id, function(err) { if (err) { console.log(err); } else { console.log("Offer confirmed"); } }); } else { console.log(`Offer #${offer.id} sent successfully`); } }); }); }); community.setCookies(cookies); }); manager.on('sentOfferChanged', function(offer, oldState) { console.log(`Offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`); }); manager.on('pollData', function(pollData) { fs.writeFile('polldata.json', JSON.stringify(pollData), function() {}); }); /* * Example output: * * Logged into Steam * Got API key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx * Found 117 CS:GO items * Offer #1601569319 sent, but requires confirmation * Offer confirmed */ https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/blob/master/examples/offloader.js Quote Link to comment Share on other sites More sharing options...
SunriseM Posted May 8, 2017 Report Share Posted May 8, 2017 (edited) Oh so you were using this example code. In this part: var offer = manager.createOffer("https://steamcommunity.com/tradeoffer/new/?partner=12345678&token=xxxxxxxx"); you have to put a real trade link. Also what error are you getting in the console? Edited May 8, 2017 by SunriseM Quote Link to comment Share on other sites More sharing options...
Ferriar_幽助 Posted September 22, 2017 Report Share Posted September 22, 2017 Just remove the code if you just want send 1 item. offer.addMyItems(inventory); have a try! Quote Link to comment Share on other sites More sharing options...
Andrei Elvis Posted September 27, 2017 Report Share Posted September 27, 2017 Instead of this: offer.addMyItems(inventory[0]); Replace with this: (the code below will add all items from bot to the offer). for(var k in inventory) { offer.addMyItem({ 'assetid': inventory[k].assetid, 'appid': 730, 'contextid': 2 }); } Quote Link to comment Share on other sites More sharing options...
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.