jensej Posted November 16, 2016 Report Posted November 16, 2016 (edited) Hello.Why I get two diffrent assetid from getReceivedItems and LoadInventory? here is my code sample: manager.on('sentOfferChanged', function(offer, oldState) { if(offer.state == TradeOfferManager.ETradeOfferState.Accepted) { offer.getReceivedItems(function(err, items) { items.some(function(item) { //here save item.assetid to database. } } } }); Next I do: manager.loadInventory(730, 2, true, function(err, inventory, currencies) { //here I get saved asseid from database and loadInventory //item.asset_id is row from database inventory.forEach(function(gun) { gun.id, item.asset_id // all elements in inventory are always different but should be this same. if(gun.assetid == item.asset_id) }); Could someone tell me any tip? Edited November 16, 2016 by jensej Quote
Dr. McKay Posted November 17, 2016 Report Posted November 17, 2016 Show all your code please. And indent it properly so it's readable. Quote
jensej Posted November 17, 2016 Author Report Posted November 17, 2016 Show all your code please. And indent it properly so it's readable. manager.on('sentOfferChanged', function(offer, oldState) { console.log("Offer #" + offer.id); if(offer.state == TradeOfferManager.ETradeOfferState.Accepted) { connection.query('SELECT `id`,`steamid` FROM `offers` WHERE `offerid` = \''+offer.id+'\' and status = 2').then(function(w) { console.log("#2"); offer.getReceivedItems(function(err, items) { if(err) { console.log("Couldn't get received items: " + err); } else { console.log("#3"); var l = 0; var suma = 0; items.some(function(item) { console.log(item); tab_prices.some(function(ob) { if(item.market_hash_name == ob.name) { //console.log("#5"); if(ob.price >= 0.3) { //console.log("#6"); var a = { name: item.market_hash_name, img: item.icon_url, asset_id: item.id, price:ob.price, offerid: offer.id}; connection.query('INSERT INTO items SET ?', a, function(err,res){ if(err) throw err; suma = suma + parseFloat(ob.price); if(items.length == l) { connection.query('UPDATE `offers` SET `status`= 3 WHERE `offerid`=\''+offer.id+'\' and status = 2').then(function(o){ if(o.changedRows == 1){ var tax = suma*0.1; var pkt = suma - tax; var employee = { earned: tax, typ_wpln: 1, offers_id: offer.id}; connection.query('INSERT INTO money SET ?', employee, function(err,res){ console.log(err); connection.query('UPDATE `users` SET `points` = `points`+ \''+pkt+'\' WHERE `steamid`=\''+w[0].steamid+'\'').then(function({ if(b.changedRows > 0) console.log('#OfferID:' + offer.id + ' #Pkt: ' + pkt + ' #SteamID: ' + w[0].steamid + ' Tax: ' + tax); }); }); } }); } }); } else { connection.query('UPDATE `offers` SET `status`= \''+offer.state+'\' WHERE `offerid`=\''+offer.id+'\' and status = 2').then(function(o){ console.log('#OfferID: ' + offer.id + ' #Status '+ offer.state); }); } l++; } }); }); } }); }); } else { connection.query('UPDATE `offers` SET `status`= \''+offer.state+'\' WHERE `offerid`=\''+offer.id+'\' and status = 2').then(function(o){ console.log('#OfferID: ' + offer.id + ' #Status '+ offer.state); }); } }); setInterval(function(){ manager.loadInventory(730, 2, true, function(err, inventory, currencies) { if (err) console.log(err); else { connection.query('SELECT `items`.`asset_id`,`items`.`id` as `itemid`,`items`.`steamid`,`users`.`tradelink` as `tradelnk` FROM `items` JOIN `users` ON `users`.`id` = `items`.`buyer_id` WHERE `items`.`status`= 1').then(function(row) { console.log(row); row.forEach(function(item) { console.log(item.tradelnk); var offer = manager.createOffer(item.tradelnk); inventory.forEach(function(gun) { console.log(gun.id, item.asset_id); if(gun.assetid == item.asset_id) { offer.addMyItem(gun); var uniqcode = Math.random().toString(36); offer.send("Uniqcode:" + uniqcode, item.tradeaccess, function(err, csgo) { if (err) { connection.query('UPDATE `items` SET `status`= 12 WHERE `id`=\''+item.itemid+'\'').then(function(o){ var d = new Date(); console.log("[Data]: "+ d +" [OfferID]: " + offer.id + " [UniqCode]: " + uniqcode + " [ItemID]: " + item.itemid + " [Error]: " + err); }); } else { connection.query('UPDATE `items` SET `link`= \''+offer.id+'\', `status`= 2,`uniqcode`=\''+uniqcode+'\' WHERE `id`=\''+item.itemid+'\'').then(function(o){ var d = new Date(); console.log("[Data]: "+ d +" [OfferID]: " + offer.id + " [UniqCode]: " + uniqcode + " [ItemID]: " + item.itemid ); }); } }); } }); }); }); } });}, 30000); Quote
Dr. McKay Posted November 17, 2016 Report Posted November 17, 2016 I'm not sure I'm following. An offer is accepted, you call getReceivedItems and save its ID. Then you load your inventory and the ID of the item in your inventory is different? Quote
jensej Posted November 17, 2016 Author Report Posted November 17, 2016 I'm not sure I'm following. An offer is accepted, you call getReceivedItems and save its ID. Then you load your inventory and the ID of the item in your inventory is different?exactly Quote
Dr. McKay Posted November 17, 2016 Report Posted November 17, 2016 That shouldn't be possible. All I can figure is that you aren't grabbing the same item, or else it's already left your inventory. 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.