Jump to content
McKay Development

Is this possible? (thanks for help)


Recommended Posts

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

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!

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...