xLeeJYx Posted June 12, 2017 Report Posted June 12, 2017 This is my code, how can know what will i be traded ? i want it to log it in the console manager.on('newOffer', (offer) =>{ console.log(magenta + ('Received 1 new offer') + white); console.log(magenta + offer.partner.toString() + white + ' offered their ' + magenta + offer.itemsToReceive + white + ' for our ' + magenta + offer.itemsToGive + white) }); with this code im receiving this in console Received 1 new offer76561198330320024 offered their [object Object] for our [object Object] Quote
Dr. McKay Posted June 12, 2017 Report Posted June 12, 2017 itemsToGive and itemsToReceive are both arrays. If you don't know what this means, please take some online classes on JavaScript. Quote
xLeeJYx Posted June 13, 2017 Author Report Posted June 13, 2017 (edited) what should i type so that, what is offered will be displayed in the console and check if it is containing tf2 items only ? Edited June 13, 2017 by xLeeJYx Quote
xLeeJYx Posted June 14, 2017 Author Report Posted June 14, 2017 Anyone can help me with this ? ;_; Quote
jafix Posted June 14, 2017 Report Posted June 14, 2017 As McKay said, offer.itemsToGive is an array of items you will loose after the trade and offer.itemsToReceive is an array of items you will receive after the trade. Quote
xLeeJYx Posted June 14, 2017 Author Report Posted June 14, 2017 ok i've got it to write down whats offered in console. This is the current code... manager.on('newOffer', (offer) =>{ console.log(trade + 'Received 1 new offer : #' + offer.id); console.log(trade + magenta + offer.partner.toString() + white + ' offered their ' + magenta + offer.itemsToReceive + white + ' for our ' + magenta + offer.itemsToGive + white); if(offer.itemsToGive == 0){ console.log(trade + 'Offer #' + offer.id + ' is a gift offer, accepting'); offer.accept(function (err){ if(err){ console.log(err) } }) }else{ console.log(trade + 'Our Items') console.log(offer.itemsToGive) console.log(trade + 'Their Items') console.log(offer.itemsToReceive) if(offer.itemsToReceive == 'Scrap Metal'){ console.log('Scrap metal found on partner\s offer !') } } }); I wanna make it check if the appid/market_hash_name is match something i want sell. how to i do it ? i tried... and it dont seem to work. Again i know i suck :c if(offer.itemsToReceive.appid == '440'){ console.log(trade + 'It\'s a TF2 trade!' )} Quote
TomYoki Posted June 14, 2017 Report Posted June 14, 2017 offer.itemsToReceive.forEach(function(item) { if (item.appid == "440" && item.market_hash_name == "Scrap Metal") { console.log("It's a bird! It's a plane! IT'S A SCRAP METAL!"); } } ); Something I made you real quick. You can do it the same way for itemsToGive You can also get some of this info out of it:https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItem xLeeJYx 1 Quote
xLeeJYx Posted June 15, 2017 Author Report Posted June 15, 2017 In offer.itemsToReceive.forEach(function(item) { if (item.appid == "440" && item.market_hash_name == "Scrap Metal") { console.log("It's a bird! It's a plane! IT'S A SCRAP METAL!"); } } ); Something I made you real quick. You can do it the same way for itemsToGive You can also get some of this info out of it:https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItemWow thanks man Quote
xLeeJYx Posted June 15, 2017 Author Report Posted June 15, 2017 manager.on('newOffer', (offer) =>{ function getpitems(){ offer.itemsToReceive.forEach(function(item) { if (item.appid == "440") { console.log(Status + 'All items are TF2 items'); }else{ console.log(Status + '1 or more of our items isn\'t TF2 items!') }; }) } function getoitems(){ offer.itemsToGive.forEach(function(item){ if(item.appid == "440"){ console.log(Status + 'All items are TF2 items') }else{ console.log(Status + '1 or more of our items isn\'t TF2 items!') } }) } getpitems(); getoitems(); if(getpitems.item.appid && getoitems.item.appid == '440'){ offer.accept((err) =>{ if(err){ console.log(err) } }) }else{ offer.decline((err) =>{ if(err){ console.log(err) } }) } }) ive make them into functions so i dont mess them up if(getpitems.item.appid && getoitems.item.appid == '440'){ offer.accept((err) =>{ if(err){ console.log(err) } }) }else{ offer.decline((err) =>{ if(err){ console.log(err) } })Hmm how do i make it accept the offer if the items are tf2 items ? The code up there is just something useless i tried to make Quote
shizzo Posted June 26, 2017 Report Posted June 26, 2017 You should consider rechecking for the appid. // We have to use application IDs in our requests var appid = { TF2: 440, DOTA2: 570, CSGO: 730, Steam: 753 }; var gameappid = appid.TF2; You can try to compare your Items with this GameID 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.