Jump to content
McKay Development

McMuffinDK

Member
  • Posts

    49
  • Joined

  • Last visited

Posts posted by McMuffinDK

  1. This is the code i use at the moment

    "use strict";
    
    const OPSkinsAPI = require('@opskins/api');
    const opskins = new OPSkinsAPI(Your OPSkins API);
    const mysql = require('mysql');
    
    var con = mysql.createConnection({ // Your MySQL connection details
    	host: '',
    	user: '',
    	password: '',
    	database: ''
    });
    
    con.connect( (err) => {
    	if (err) {
    		throw err;
    	} else {
    		console.log('MySQL connected');
    	}
    });
    
    setInterval( () => {
    
    	if (new Date().getHours() === 22) {
    
    		opskins.getPriceList(730, ( (err, prices) => {
    			if (err) {
    				console.log(err);
    			} else {
    				var names = Object.getOwnPropertyNames(prices);
    
    				for (var i = 0; i <= names.length; i++) {
    
    					var n;
    
    					setTimeout( (i) => {
    
    						if (i < names.length) {
    							var name = '"' + names[i] + '"';
    							var named = names[i];
    							var date = Object.getOwnPropertyNames(prices[named]);
    							var price = prices[named][date[0]].price;
    
    							var sql = "INSERT INTO pricing(name, price) VALUES(" + name + ", " + price + ") ON DUPLICATE KEY UPDATE price = " + price + ";";
    
    							con.query(sql, (err) => {
    								if (err) {
    									throw err;
    								} else {
    									n = i + 1;
    									console.log('Updating prices.. ' + n + '/' + names.length);
    
    									if (n === names.length) {
    										console.log('Prices updated');
    									}
    								}
    							});
    						}
    
    					}, 10 * i, i);
    				}
    			}
    		}));
    	}
    }, 3600000);
    
  2. You can put a function that does something with the callback

    Price.getPrice(tag, craft, itemName, (price, priceType) => {
        console.log("Price: " + price);
        console.log("Price Type: " + priceType)
    });
    
    • tag : A string that includes your tag like "Vintage","Unique" and "Vintage"

    • craft: A string that includes your craft type like "Craftable" or "Non-Craftable"

    • itemName: A string that includes your items full name on BP.TF like "Taunt: Kazotsky Kick"

    • price: Price of item.

    • priceType: Type of price. Returns "key" or "ref"

     

    I would like to recommend the OPSkins API for your pricing as you need less calls and you are not depending on another service to be online as you can save all the prices in a database or file. If you want i can provide an example code for this too

  3. I have this code to get the items of a specific user, but it should work for every user in the world, so i want to use a variable instead of hardcoding the steamID64 into it, but i just can't get it to work

    var qqdata = steamID64; // the steamid64 of the user i want to get the inventory from
    
    const offer = manager.createOffer + qqdata;
    
    offer.getPartnerInventoryContents(730, 2, (err, inventory) => {
    if (err) {
    console.log(err);
    } else {
    for (var i = 0; i < inventory.length; i++) {
    
    setTimeout(function (i) {
    
    var name = "'" + inventory[i].market_hash_name + "'";
    
    var image = "'" + inventory[i].icon_url + "'";
    
    var sql = "INSERT INTO `inventorys`.`" + qqdata + "` (name, icon_url) VALUES (" + name + ", " + image + ")";
    
    con.query(sql, function (err) {
    if (err) {
    console.log(err);
    }
    });
    
    }, 10 * i, i);
    }
    }
    });
    

     

     

×
×
  • Create New...