Jump to content
McKay Development

DGVaniX

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by DGVaniX

  1. What you have there will work provided the user does have 350 gems in their first gem stack. It's possible to have multiple gem stacks, so you'd need to iterate the gems array and total up all the amounts to see how much the user has, then add the appropriate amount from each stack if they do.

    Thanks for the reply.

     

    I don't really understand what you said there... I'm not really a programmer so I don't really know the terminology. How do I 'iterate' the array? And how do I add gems from each stack?

     

    Thanks.

     

    --- EDIT

     

    So I've googled this a bit and found some codes and I tried to use those examples but its TOO CONFUSING, I don't understand how to do it...

    manager.getUserInventoryContents(steamID, 753, 6, true, function(err, inv) {
    				if (err) {
    					bot.chatMessage(steamID, "An error occurred while loading your inventory. Please try later");
    				}else{
    					if (ERR) {
                            client.chatMessage(steamID, "An error occurred while loading your inventory. Please try later");
                        } else {
                            var gemsAmount = 0;
    						var botGems = [];
    						for (var i = 0; i < inv.length; i++) {
                                if (CONFIG.STEAMGEMS.indexOf(inv[i].market_hash_name) >= 0) { //Don't know what to put in 'CONFIG.STEAMGEMS', I just copy/pasted
                                    botgems = inv[i].amount;
                                    gemsAmount = INV[i].amount;
                                    inv[i].amount = itemAmount
                                    botGems.push(inv[i]);
                                    break;
                                }
                            }
                            if (botgems < itemAmount) {
                                client.chatMessage(steamID, "You don't have enough gems to send. (You have " + botgems + " gems)");
    						} else {
                                t.addTheirItems(botgems);
                                t.send();
                                client.chatMessage(steamID, "You sent me " + itemAmount + " gems.");
                            }
    
  2. Hi, so I'm making a bot that send the user a trade offer with 350 gems, but the problem is that it's my first time using JS, so I find it kinda difficult to do it...

     

    I found this online but I don't understand it at all....:

                                               manager.getUserInventoryContents(steamID, 753, 6, true, (err, inv) => {
    						if (err) {
    							throw err;
    						}
    						
    						let gems = inv.filter(item => item.market_hash_name == "Gems");
    						let item = gems[0];
    						item.amount = 350;
    						offer.addMyItem(item);
    					
    						offer.send(function(err, status) {
    							if (err) {
    								console.log(err);
    								return;
    							}
    
    							//Some code
    						});					
    					});
    

    But the problem is that I need:

     

    1. Check if the user has at least 350 Gems or more in their inventory

    2. Send the trade offer with the 350 gems

     

    So I basically have no idea how to do it...

     

    Anyone can help me out?

     

    Thanks.

  3. Hi, so I am making a bot and the user has a "!buy" command that also has a parameter. How do I find out what number the user enters after the command when the user enters it like this "!buy 3"?

    if (msg.toUpperCase() == '!BUY' && '!BUY' == msg.toUpperCase().substring(0,4)){
    				if(!isNaN(msg.charAt(5)) && parseInt(msg.charAt(5)) > 0){
    					var string_start=msg.indexOf("UY");
    					var nrOfSets= "";
    					string_start+=3;
    					for (var i = string_start; i < msg.length; i++) { 
    						nrOfSets+= msg.charAt(i);
    					}
    					var sets = parseInt(nrOfSets);
    

    I tried that but it doesn't work, it just skips to the last "else" which tells the user that the command is not recognized...

     

    Thanks.

     

    ---- EDIT

     

    FIXED!

  4. Hi, so I need a bit of help on making a bot using node-steam, and I've noticed that there's only node-steam-user on this forum which might not be the same as node-steam so I thought I might as well post in general.

     

    I'm making this bot and I want it to automatically message people who message the bot with a predefined message:

        var Steam = require('steam');
        var fs = require('fs'); 
        var bot = new Steam.SteamClient();
    	
        if (fs.existsSync('sentryfile_' + process.argv[2])){
            var sentry = fs.readFileSync('sentryfile_' + process.argv[2]);
    		console.log('[BOT] logging in with sentry ');
            bot.logOn({
        		accountName: process.argv[2],
        		password: process.argv[3],
        		authCode: process.argv[5],
        		shaSentryfile: sentry
            });
        }else{
    		console.log('[BOT] logging in without sentry');
            bot.logOn({
        		accountName: process.argv[2],
        		password: process.argv[3],
        		authCode: process.argv[5]
            });
        }
    	
    

    This is my first bot in js and I can't see the predefined functions of node-steam anywhere...

     

    Thanks.

×
×
  • Create New...