Jump to content


Photo
Question

Is this possible? (thanks for help)

node.js node-steam-tradeoffer-manager

Best Answer FallingLight , 10 December 2018 - 01:56 PM

Thanks, i will try soon.

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 FallingLight

FallingLight

    Newbie

  • Member
  • Pip
  • 6 posts

Posted 08 December 2018 - 06:03 PM

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.


#2 SnaBe

SnaBe

    Member

  • Member
  • PipPip
  • 25 posts
  • LocationDenmark

Posted 09 December 2018 - 07:26 AM

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!



#3 FallingLight

FallingLight

    Newbie

  • Member
  • Pip
  • 6 posts

Posted 10 December 2018 - 01:56 PM   Best Answer

Thanks, i will try soon.







Also tagged with one or more of these keywords: Question, node.js, node-steam-tradeoffer-manager

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users