IdiotScriptieKid Posted May 16, 2017 Report Posted May 16, 2017 I am entirely new on java script and learning on day by day, i want to get on sending the items in a steam bots inventory. Sending it one by one and loops until the inventory is empty. Sorry for the trouble this might be spoon feeding the code to me, i can not get it undone its been lingering in my mind to post this, but i cant seem to do it because its kinda shameful, but i did it anyways. It will be a great help for my research. I just want somebody to modify the example code of the great doctormckay the offloader.js, in which it will send the items one by one and loops until the inventory is empty. Thank you in advance /** * 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('../lib/index.js'); // 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.loadInventory(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); 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 */ Quote
SunriseM Posted May 17, 2017 Report Posted May 17, 2017 (edited) Hello. If you showed us what you have tried it would be better, so we can explain you what's wrong with your code. To help you a little: For this i would make a loop through the inventory, and inside call a function that sends the offer. To get each item you have to use inventory[number]. If you still can't manage to get it to work, comment here what you tried. Also sending so many offers (depending of your inventory size) in a short of time is not a good idea. Edited May 17, 2017 by SunriseM Quote
Jermay dao Posted May 22, 2017 Report Posted May 22, 2017 I am also curious about this subject, well infact I am new with javascript also. I tried what you said , putting inventory[1] or 0, and literally put a string number. like trying to send any item without definite name. var offer = manager.createOffer("https://steamcommunity.com/tradeoffer/new/?partner=291070862&token=tWXn6IyJ"); offer.addMyItems(inventory[1]); offer.setMessage("Here, have some items!"); Quote
Dr. McKay Posted May 23, 2017 Report Posted May 23, 2017 addMyItems will only work with an array of multiple items (which is what inventory is). You need to use addMyItem to add a single item (e.g. a single element from inventory). The inventory[1] syntax retrieves element #1 from the inventory array (an array is essentially a list). Note that since numbering starts at 0, element #1 is the second ordinal element. Quote
IdiotScriptieKid Posted May 26, 2017 Author Report Posted May 26, 2017 Thank you for the help, now I understand I literally broke my head and the answer was pretty obvious, thank you very much such a helpful community. But how can I make this as a loop? is there an example code that i can refer? Much appreciated! Quote
Dr. McKay Posted May 26, 2017 Report Posted May 26, 2017 What do you mean? Do you want to iterate over each element in an array? Quote
AlaDyn172 Posted June 6, 2017 Report Posted June 6, 2017 for(var i in inventory){ create.addMyItems({ "assetid": inventory.assetid, "appid": applicationid, "contextid": 1/2 (depends which appid is) });} Quote
Dr. McKay Posted June 7, 2017 Report Posted June 7, 2017 for(var i in inventory){ create.addMyItems({ "assetid": inventory.assetid, "appid": applicationid, "contextid": 1/2 (depends which appid is) });} This won't work because you're calling addMyItems on a single item. You should use addMyItem instead. Quote
AlaDyn172 Posted June 8, 2017 Report Posted June 8, 2017 This won't work because you're calling addMyItems on a single item. You should use addMyItem instead.Yes my bad, I copied his line, and forgot to edit to addMyItem 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.