TextDynasty Posted February 5, 2018 Report Posted February 5, 2018 Is there a way to set a variable of the price by using this package? https://github.com/tarikkiziltan/getPrice I saw there's var Price = require("./getprice.js") //var price = new Price(tag,craft,item,callBack) // What should i put in the callback if i want to use the price? Thanks Price.getPrice("Vintage","Craftable","Gunslinger",function(price,priceType) { console.log("It's " + price + " " + priceType); }) Quote
McMuffinDK Posted February 6, 2018 Report Posted February 6, 2018 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 Quote
TextDynasty Posted February 6, 2018 Author Report Posted February 6, 2018 That would be great if you could provide help Quote
McMuffinDK Posted February 6, 2018 Report Posted February 6, 2018 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); Quote
TextDynasty Posted February 6, 2018 Author Report Posted February 6, 2018 Oh i think it is not suitable for tf2 trading Quote
McMuffinDK Posted February 6, 2018 Report Posted February 6, 2018 (edited) Ah sorry, didn't realize it was for TF2. Try change the appid to 440: opskins.getPriceList(440, ( (err, prices) => Edited February 6, 2018 by McMuffinDK Quote
TextDynasty Posted February 7, 2018 Author Report Posted February 7, 2018 I was expecting using ingame currencies Quote
McMuffinDK Posted February 7, 2018 Report Posted February 7, 2018 Sorry, i do not know anything about that Quote
Recommended Posts
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.