FallingLight Posted December 8, 2018 Report Posted December 8, 2018 Hy, i'm new in node js, my english is not that good. First, i wanna make a script which is load the player's inventory, accept all keys expect low price keys (like hydra case key or CSGO capsulekey),t hen select ? keys (depends on what command he uses in the chat (!buyadmin->3keys, !buyvip->2keys)).After the select, the bot will send an offer for the keys and he gets his rank (I can make this part).I have a starter script (I tried to learn and code something). Code: const SteamUser = require('steam-user');const SteamTotp = require('steam-totp');const SteamID = require('steamid');const SteamCommunity = require('steamcommunity');const TradeOfferManager = require('steam-tradeoffer-manager');const config = require('./config.json'); const client = new SteamUser();const community = new SteamCommunity();const manager = new TradeOfferManager({ steam: client, community: community, language: 'en'}); const logOnOptions = { accountName: config.username, password: config.password, twoFactorCode: SteamTotp.generateAuthCode(config.sharedSecret)}; client.logOn(logOnOptions); client.on('loggedOn', () => { console.log('[Vortex] Sikeres bejelentkezés a steam-be!'); client.setPersona(SteamUser.Steam.EPersonaState.Online); client.gamesPlayed(730);}); client.on('webSession', (sessionid, cookies) => { manager.setCookies(cookies); community.setCookies(cookies); community.startConfirmationChecker(10000, config.identitySecret);}); manager.on('newOffer', offer => { if (offer.partner.getSteamID64() === 'config.owenerID') { offer.accept((err, status) => { if (err) { console.log(err); } else { console.log(`[Vortex] Owner csereajánlat elfogadva. Státusz: ${status}.`); } }); } }); client.on("friendMessage", function(steamID, message) { if (message == "!help") { client.chatMessage(steamID, "[Vortex] Parancsok: !weboldal, !szerverek, !rangok, !adminok, !buyadmin, !buyvip+, !buyvip, !buypskin");console.log(steamID.getSteam2RenderedID()); } if (message == "!weboldal") { client.chatMessage(steamID, "[Vortex] Weboldalunk: ");console.log(steamID.getSteam2RenderedID()); } if (message == "!szerverek") { client.chatMessage(steamID, "[Vortex] Szervereink: ");console.log(steamID.getSteam2RenderedID()); } if (message == "!rangok") { client.chatMessage(steamID, "[Vortex] Rangok: ");console.log(steamID.getSteam2RenderedID()); } if (message == "!adminok") { client.chatMessage(steamID, "[Vortex] Adminok: ");console.log(steamID.getSteam2RenderedID()); } if (message == "!buyadmin") { client.chatMessage(steamID, "[Vortex]");const steam2id = (steamID.getSteam2RenderedID());const steamid = (steamID.getSteamID64());const offer = manager.createOffer(steamid); community.getUserInventory(steamid, 730, 2, false, function(err, inventory) {console.log(inventory[0].amount);}); } if (message == "!buyvip+") { client.chatMessage(steamID, "[Vortex]"); } if (message == "!buyvip") { client.chatMessage(steamID, "[Vortex]");console.log(steamID.getSteam2RenderedID()); } if (message == "!buypskin") { client.chatMessage(steamID, "[Vortex]");console.log(steamID.getSteam2RenderedID()); } if (message != "!help" && message != "!weboldal" && message != "!rangok" && message != "!adminok" && message != "!buyadmin" && message != "!buyvip+" && message != "!buyvip" && message != "!buypskin"){client.chatMessage(steamID, "[Vortex] Nincs ilyen parancs, segítségért írd be: !help");}}); manager.on('newOffer', offer => { if (offer.itemsToGive.length === 0) { offer.accept((err, status) => { if (err) { console.log(err); } else { console.log('[Vortex] Támogatás elfogadva. Státusz: ${status}.'); } }); } else { offer.decline(err => { if (err) { console.log(err); } else { console.log('[Vortex] Támogatás elutasítva. (Tárgyat akart kérni a bot-tól!)'); } }); }}); (steamID.getSteam2RenderedID()); -> I need this for sourcemod admin setup. Quote
SnaBe Posted December 9, 2018 Report Posted December 9, 2018 Yes, this is possible. Use steam-tradeoffer-managers getUserInventoryContents to load the user's inventory, then loop through and search for the items you need. Make a variable that stores the specific keys you want and add up. If they have the required amount to purchase admin, store the keys in an array, if not simply notify the user and return true. As the final step, you need to create a new trade offer, add the items, send and confirm the trade offer. I hope this helps! Quote
FallingLight Posted December 10, 2018 Author Report Posted December 10, 2018 Thanks, i will try soon. 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.