Jump to content
McKay Development

Lonster_Monster

Member
  • Posts

    25
  • Joined

  • Last visited

Posts posted by Lonster_Monster

  1. I am working on a site and want to get steam items with nodejsand express i understand how to get item inventory and i am using the get-steam-inventory npmmodule and not sure on why the backpack is not being generated in the express below is the price.js file i have for price.pug and in the pug file i call each item in items and cannot get the value of length any help would be appreciated

    var express = require('express');
    
    var router = express.Router();
    //var pages = require('../pages/Pages.json');
    //var quality = require('../public/730/quality.json')
    var fs = require('fs');
    var data;
    var steamid;
    var backpack;
    var appid = 440;
    const steaminventory = require('get-steam-inventory');
    
    /* GET users listing. */
    router.get('/', function(req, res, next) {
        // render template
    	steamid = req.user.steamid
    	var path = './public/json/'+steamid+'.json';
    	checkFile(path);
        res.render('price', {user: req.user, items: req.backpack});
    	console.log(backpack)
    });
    function checkFile(path) {
    	try {
    		if (fs.statSync(path)) {
    			fs.readFile(path,"utf8", (err, backpack) => {
    			  if (err) throw err;
    			backpack = backpack
    			});
    		}
    	} catch(err) {
    		steaminventory.getinventory(appid, steamid, function(err, items){
    		  if(err) {
    			return console.log("Error, while getting user items. Please check settings or user inventory is hidden.");
    		  } else {
    			if (items){
    				fs.writeFile(path, JSON.stringify(items.raw, null, 4), { flag: 'w' }, function (err) {
    					if (err) throw err;
    					console.log('\x1b[32m','The file has been saved!','\x1b[0m');
    				});
    
    			}
    			checkFile(path)
    		  }
    		})
    	}
    }
    
    
    module.exports = router;
    
    
    
  2. I know the steam api doesnt have an api to send steam tradeoffers in php how can i  send one by trade link?

     

    I want to have a site that u Select items to buy and it will send trade offers with those items and wandering how to do it from php with the trade offer link

  3. What is the Best way to call steam api for steam items i have been using

    $id = "76561198147982809";
    $query = "http://steamcommunity.com/profiles/".$id."/inventory/json/440/2/";;
    $json = file_get_contents($query);
    $data = json_decode($json, true);
    

    to get my bots inventory of course has 0 tradable items and get the failed error alot

    failed to open stream: HTTP request failed! HTTP/1.0 429 Too Many Requests
    

    is calling the

    http://steamcommunity.com/profiles/[steamid]/inventory/json/440/2/
    

    the best way i am creating a website like scrap.tf for my steam bots to buy and sell items

    if there is a better way Please let me know i know some about the steam API but not the most about it and not sure which would be best if i use that

    and also if i upload my site onto my host will it do the errors alot or just when client calls the json i used?

  4. I finally fixed the problem in

      var item = ourItems[i].market_name;
      var des = ourItems[i].descriptions;
      console.log(item)
      console.log(des)
      if (item == stock[item] && des == stock[item].description){
      if (item == Prices[item] && des == Prices[item].description){
      console.log(Prices[item].sell)
      }
    }
    

    changed the code to the code below and i think it is cool how i can call stuff like this now

    const filestockname = './/settings/Prices/Prices.json';
    		const filestock = require(filestockname);
    		for (var i in ourItems) {
    			var item = ourItems[i].market_name;
    			var des = ourItems[i].description
    			console.log(item)
    			console.log(des)
    			if (filestock[item]){
    			fs.readFile(filestockname, (err, data) => {
    			if (err) throw err;
    			console.log('File read');
    			});
    			filestock[item].description = des
    			console.log('writing to ' + filestockname);
    			fs.writeFile(filestockname, JSON.stringify(filestock, null, 2), function (err) {
    			if (err) return console.log(err);
    			console.log('writing to ' + filestockname);
    			});
    			}
    		}	
    

    that is only for the our items side i didnt post for the their items side of the trade becaseu it is basically the same

  5. Objects would just work fine as string..

    var object = {

        'this_works':'it actually did!'

    };

     

    console.log(object.this_works);

    ..?

    so say i wanted to do the code i have above, what exactly would i do i mean as an object like i am wanting

     

    Sorry if it is a noob question i am still kinda new to nodejs i have been making my own bot for about a year leanring new stuff in it

  6. i have a genuine killer exclusive with the australium paint on it

    i done

      var item = ourItems[i].market_name;
      var des = ourItems[i].descriptions;
      console.log(item)
      console.log(des)
      if (item == stock[item] && des == stock[item].description){
      if (item == Prices[item] && des == Prices[item].description){
      console.log(Prices[item].sell)
      }
    }
    

    when it does the console log on item and des it shows

    	"Genuine Killer Exclusive":
    	[ { 
        type: "text",
        value: "Paint Color: Australium Gold",
        color: "756b5e",
        app_data: "" },
    	{ 
        type: "text",
        value: "Break news, spirits and heads.",
        app_data: "" 
    	} ]
    

    i put the descriiption text in the stock under the item name and is the value of description like below

    {
    "Genuine Killer Exclusive":
     {
     "instock": 0,
     "stocklimit":1,
     "description": 
      [ { 
      "type": "text",
      "value": "Paint Color: Australium Gold",
      "color": "756b5e",
      "app_data": "" },
      { 
      "type": "text",
      "value": "Break news, spirits and heads.",
      "app_data": "" 
      } ]
     }
    }
    

    the problem is with the "" around type, value, color, app_data, type, value, app_data  it acts as if that is not the value but json wont work without the " " around the certain words

     

    SOLUTION:

     

     

    I finally fixed the problem in


    var item = ourItems[i].market_name;
    var des = ourItems[i].descriptions;
    console.log(item)
    console.log(des)
    if (item == stock[item] && des == stock[item].description){
    if (item == Prices[item] && des == Prices[item].description){
    console.log(Prices[item].sell)
    }
    }

    changed the code to the code below and i think it is cool how i can call stuff like this now


    const filestockname = './/settings/Prices/Prices.json';
            const filestock = require(filestockname);
            for (var i in ourItems) {
                var item = ourItems[i].market_name;
                var des = ourItems[i].description
                console.log(item)
                console.log(des)
                if (filestock[item]){
                fs.readFile(filestockname, (err, data) => {
                if (err) throw err;
                console.log('File read');
                });
                filestock[item].description = des
                console.log('writing to ' + filestockname);
                fs.writeFile(filestockname, JSON.stringify(filestock, null, 2), function (err) {
                if (err) return console.log(err);
                console.log('writing to ' + filestockname);
                });
                }
            }    

    that is only for the our items side i didnt post for the their items side of the trade becaseu it is basically the same

  7. an Idea for that there is get the inspection link and people can just see it ingame like that or right click the item in steam inventory the view source and get the i might be commnuity.edgecast steamstatic pic and to know wich one u r getting it will say alt = (name of item) 

    Ex.( http://community.edgecast.steamstatic.com/economy/image/-9a81dlWLwJ2UUGcVs_nsVtzdOEdtWwKGZZLQHTxDZ7I56KU0Zwwo4NUX4oFJZEHLbXH5ApeO4YmlhxYQknCRvCo04DEVlxkKgposLOzLhRlxfbGTj5X09q_goWYkuHxPYTZj3tU-sd0i_rVyoHwjF2hpiwwMiukcZjGegU8M1_Qr1i5ye_sh5_otM7OzHFrvCEm43jZnxLm100ZaLBqgfybVxzAULwEhsV8/330x192 alt fiveseven

  8. The Error I am Getting is

    var item = theirItems.market_name

                                      ^

    Type:Error: Cannot read property 'market_name' of undefined

     

    it is the The Trade Offer part of my Code the Code Is Below

     

    That is to Process Their Items in the Trade Offer

    for (var i in theirItems) {
                var item = theirItems[i].market_name
                if (stock[item]){
                    currentstock = stock[item].instock;
                    StockLimit = stock[item].stocklimit;

    I ahve been Creating My OWn Code and not sure why the Error i got has Occurred

  9. I am fairly new to nodejs and have posted other questions on this forum and i am learning a lot form this forum

     

    Question:

    How do i use the steam webAPI get commands with the node-steam-user, node-steamcommunity, node-steam-tradeoffer-manager, and node-steam-totp.

     

    Those are the steam npm packages i am using.

     

    The webAPI Command i want to call is:

    GET https://api.steampowered.com/ISteamEconomy/GetAssetPrices/v1/

    I understand it needs my apikey + appid

     

    Appid = i think it is 753_6 for to use it with trading cards

    i am not sure if that is even the correct webAPI caller

     

    I want it to get the names and prices of the Trading Cards and Backgrounds

    if possible all in a .json where i could see it at one time

  10. i have been trying to get my steam bot to do automatic buy and selling meaning that it has a stock management system and i almost got one that i created from messing around in nodejs i got it it runs the only thing i am having trouble with is an error a friend told me it might be a bug i was wandering if anyone knows what the error means

     

    Error:

    { Error: EBADF: bad file descriptor, write errno: -4083, code: 'EBADF', syscall: 'write' }

     

    does not stop the code it keeps going and accepts ust it has that as if it was part of the console.log command

     

    also i used jsonfile npm and colors npm modules

     

    Here is the full part of it

    function processOffer(offer) {
    	if (offer.isGlitched() || offer.state === 11) {
    		console.log("[".green+h+":".cyan+m+":".cyan+s+"] ".green+"Offer was glitched, declining.");
    		declineOffer(offer);
    	} else if (offer.partner.getSteamID64() === config.ownerID) {
    		acceptOffer(offer);
    	} else {
    		var ourItems = offer.itemsToGive;
    		var theirItems = offer.itemsToReceive;
    		var ourValue = 0;
    		var theirValue = 0;
    		var currentstock = 0;
    		var StockLimit = 0;
    		for (var i in ourItems) {
    			var item = ourItems[i].market_name;
    			if (stock[item]){
    				currentstock = stock[item].instock;
    				StockLimit = stock[item].stocklimit;
    				if (fs.readFileSync('.//settings/Stock/stock.json')){
    				console.log(timestamp+"Our " +item+" - stock number: " +currentstock+ " / " +StockLimit+ ".")
    				if (currentstock < StockLimit){
    					if(Prices[item]) {
    					ourValue += Prices[item].sell;
    					} else if (MetalPrices[item]){
    					ourValue += MetalPrices[item].sell;
    				} else {
    					console.log(timestamp+"Invalid Value.");
    					ourValue += 99999;
    					}
    			} else if (currentstock >= StockLimit){
    				console.log(timestamp+item +" Stock Limit Reached")
    					manager.on('receivedOfferChanged', (offer)=>{
    					if (adminConfig.disableAdminComments == "Enable") {
    						community.postUserComment(offer.partner.toString(), item+ " - Stock Limit Reached", (err)=>{
    							if(err) throw err.message
    						});
    					}
    					})
    			}
    				};
    			}
    		}					
    		for(var i in theirItems) {
    			var item= theirItems[i].market_name;
    			if (stock[item]){
    				currentstock = stock[item].instock;
    				StockLimit = stock[item].stocklimit;
    				fs.readFileSync('.//settings/Stock/stock.json')
    				console.log(timestamp+"The " +item+" - stock number: " +currentstock+ " / " +StockLimit+ ".")
    				if (currentstock < StockLimit){
    					if(Prices[item]) {
    					theirValue += Prices[item].buy;
    					} else if (MetalPrices[item]){
    					theirValue += MetalPrices[item].buy;
    					} else {
    					console.log(timestamp+"Invalid Value.");
    					theirValue += 99999;
    				}
    				} else if (currentstock >= StockLimit){
    						console.log(timestamp+item +" Stock Limit Reached")
    						manager.on('receivedOfferChanged', (offer)=>{
    						community.postUserComment(offer.partner.toString(), item+ " Stock Limit Reached", (err)=>{
    							if(err) throw err.message
    							})
    						})
    					} 
    			}
    		}
    console.log(timestamp+"Our value: "+ourValue);
    console.log(timestamp+"Their value: "+theirValue);
    
    	
    	if (ourValue <= theirValue) {
    		if (config.DevCode == "True"){
    			if (DevCodeCFG.Enable_Dev_Stock_Manager== "True"){
    				for (var i in ourItems) {
    					var item = ourItems[i].market_name;
    						if (stock[item]){
    							var file = (stock[item].instock);
    							var obj = math.subtract(currentstock, 1)
    							jsonfile.writeFile(file, function (err) {
    							console.error(err)
    							})
    					console.log(timestamp+' The file has been saved!');
    						}
    				}
    				for (var i in theirItems) {
    					var item = theirItems[i].market_name;
    						if (stock[item]){
    							var file = (stock[item].instock);
    							var obj = math.add(currentstock, 1)
    							jsonfile.writeFile(file, obj, function (err) {
    							console.error(err)
    							})
    						console.log(timestamp+' The file has been saved!');
    						}
    				}
    			}
    		}
    			acceptOffer(offer);
    		} else if (ourValue > theirValue){
    		console.log(timestamp+"Their value was different.")
    			declineOffer(offer);
    		}
    	}
    }
    

    If you want to try out my steam bot i got so far it is at github at github.com/LonsterMonster/Steam-Trade-Node-Bot

    you have to enable the developer options becasue i didnt want anyone to use the stock management that didnt know what they were doing since it is incomplete

  11. I am trying to get my steam bot to write to a file using the fs.write command here is what i got so far:

     

    if (stock[item]){
        var item = ourItems.market_name;
             fs.writeFile(stock[item].instock, stock[item].instock - 1 , (err) => {
                if (err) throw err;
                 console.log('The file has been saved!');
                });

    }

     

    but i keep getting

    \app.js:291
     if (err) throw err;
                                                       ^

    Error: EBADF: bad file descriptor, write
     

×
×
  • Create New...