Jump to content
McKay Development

SnaBe

Member
  • Posts

    43
  • Joined

  • Last visited

1 Follower

Contact Methods

  • Website URL
    https://github.com/SnaBe

Profile Information

  • Gender
    Male
  • Location
    Denmark
  • Interests
    Node.js & Java programming.

Recent Profile Visitors

2265 profile views
  1. The TF2 item servers are down, you'll have to wait until they get back up again.
  2. You probably want to listen for the 'newOffer' event using your steam-tradeoffer-manager instance.
  3. You could filter your inventory items by their market_hash_name.
  4. You can find the docs here.
  5. You can get a user's escrow days by using getUserDetails() and only send the trade offer if your trade partner's escrow days are 0, otherwise, you would cancel the offer and notify the user.
  6. Since you haven't posted any code I'm unsure how you're using the method. So I'll show you how I usually do it. Let's say you want to invite the user as soon as they become friends with yout bot, you can do it as follows: client.on('friendRelationship', (steamID, relationship) => { switch(relationship) { //The bot received a friend request from another Steam user case 2: console.log(`Bot ${client.steamID.getSteamID64()} received a friend request from user ${steamID}.`); client.addFriend(steamID, (err) => { if(err) { console.log(`Error adding user ${steamID}.`); } else { client.getPersonas([steamID], (err, personas) => { var persona = personas[steamID.getSteamID64()]; var name = persona ? persona.player_name : ("[" + steamID.getSteamID64() + "]"); client.chatMessage(steamID, `Greetings ${name}! ${config.steam.messages.new_friend}`); }); console.log(`Bot ${client.steamID.getSteamID64()} accepted user ${steamID}'s friend request.`); } }); break; //The bot is now friends with another Steam user case 3: //Invite that user to our Steam group client.inviteToGroup(steamID, config.steam.groupID); console.log(`Bot ${client.steamID.getSteamID64()} invited user ${steamID} to our Steam group.`); break; default: break; } }); The inviteToGroup methods takes two arguments, the SteamID of the user you wish to invite and the groupID for the group. The SteamID is retrieved from the friendRelationship event. You'll have to store your Steam group ID in a variable or in a separate file. I store mine in a JSON config file. If you don't have the groupID you can find it by replacing <GroupName> in this url https://steamcommunity.com/groups/<GroupName>/memberslistxml/?xml=1 with the name of your Steam group. Then you'll be able to extract the groupID from the XML file in your browser. I hope this helps!
  7. First of all, thank you for the great answer! Alright, so all I really need is to extract the owner's steamid from the inspect link. const groups = /^steam:\/\/rungame\/730\/\d+\/[+ ]csgo_econ_action_preview[%20 ]*?([SM])(\d+)A(\d+)D(\d+)$/.exec(inspectLink); Using the regex above I can get the item's owner and assetid, along with two other values I have no idea what are used for. [ 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview S76561198964582249A17986946021D14442516311341693499', 'S', '76561198964582249', '17986946021', '14442516311341693499', index: 0, input: 'steam://rungame/730/76561202255233023/+csgo_econ_action_preview S76561198964582249A17986946021D14442516311341693499', groups: undefined ] The owner's steamid is right after the 'S' and the item's assetid is the one after that. (In the inspect link they are seperated by S, A and D) Now that I've the SteamID I can retrieve the user's inventory from Steam and filter the inventory for an assetid match. But is there a smarter way to extract the steamid from an inspect link alone? And what is 'D14442516311341693499' & index used for? Are they just part of the inspect link in some way? Best regards, SnaBe.
  8. Below is a set of data that I got from using the inspectItem() method from node-globaloffensive. { "stickers": [], "accountid": null, "itemid": "17981383956", "defindex": 5035, "paintindex": 10059, "rarity": 6, "quality": 3, "paintwear": 0.19330522418022156, "paintseed": 904, "killeaterscoretype": null, "killeatervalue": null, "customname": null, "inventory": 3221225475, "origin": 8, "questid": null, "dropreason": null, "musicindex": null } Now I'm wondering, how do I get the item name & image? Is there some library or middleware I can use? I assume that defindex & paintseed are used to identify the unique item. But how exactly? I would like to get the item name and generate an image that represents the item data above. I hope that someone can help! Best regards, SnaBe.
  9. If you wish to use websockets, socket.io-client allows you to connect to another http server that's using socket.io. const io = require('socket.io-client'); const socket = io.connect('localhost:8080', { reconnect: true }); socket.on('connect', (socket) => { console.log('Connected to server!'); }); I hope this helps!
  10. You could make a seperate server for x amount of SteamUsers and use http requests to communicate with the main server.
  11. What I posted is the basics you need to know for creating commands & trades. But since you're looking for an example that solves your exact problem, this old post of mine might help. I wanted to loop trough an inventory and add the correct metal for a specific amount of Mann Co. Keys, after this I can create the trade offer. You don't see this in the post, but if you read the steam-tradeoffer-manager documentation you should be able to do it. Or just use parts of your posted code. There's not many cases out there where users have published their code for solving a specfic problem you might have. You need to use your knowlegde of NodeJS, the modules you're using and code a solution yourself. But here's how I would do it: If the item you got from the command is in your JSON file, save the price in a local varaible. Loop trough an inventory, find the items until the amount match the metal price of the item and parse them to an array. Calculating this is simple math, you can always look at my post for refference. Now you can create an offer with the createOffer method. With the theirKeys array used in the example, you've the assetids of the keys (this can be apllied for any item in Valve's games.) in the array. You just need to use the addMyItems or addTheirItems methods of the module and parse the array as an argument. This is all you need to add items to a trade offer, after this, simply send and confirm the offer. Again make use of the methods of the steam-tradeoffer-manager module. I hopes this helps!
  12. Alright, there's primarily to parts of creating a systen like this. 1. Handling chat commands / buy & sell requests from Steam chat. 2. Searching inventories for the required items and creating the trade offer. Luckily for you, other users have had similar questions regarding this topic. Here's an entry regarding chat commands. Here's an entry regarding looping trough the inventory and looking for item matches. I hope this helps!
  13. Yes, it's possible to have "inputs" in a message or command. To do so, you'll have to learn about regex. Here's an example: //Act on chat messages & commands client.on('friendMessage', (steamID, message) => { //Command place holder var cmd; //Does the message match our buy command if(cmd = message.match(/^!buy (\d+) (\D+)/i)) { //The amount to buy (input string to number) var amount = Number(cmd[1]); //The item to buy (input string) var item = cmd[2]; //Log the regex values console.log(`User ${steamID} would like to purchase ${amount} of ${item}`); //Call your function that takes these two values as arguments. sellItem(steamID, amount, item); } }); In the example above we're looking for a buy command match. The string has to start with !buy, contain a number & a set of characters. For numbers only we use 'd' & for characters we use 'D'. The number is the amount of an item to buy, while the charaters is the item's name. We can access these values by using the following notation cmd[1]. Here 1 is the first regex match & cmd[2] is the second one. The (), \ & + all have different uses, escpeially when it comes to matching something from a string using regex. You can read more about those used in the example above here. I hope this helps!
  14. There's a similar topic here.
  15. You can use Steam Trade Offer Manager to check for sent offers & check the offer state with ETradeOfferState. manager.on('sentOfferChanged', (offer, oldState) => { console.log(`Bot ${this.client.steamID.getSteamID64()}'s offer #${offer.id} changed: ${TradeOfferManager.ETradeOfferState[oldState]} -> ${TradeOfferManager.ETradeOfferState[offer.state]}`); });
×
×
  • Create New...