_Gala Posted May 27, 2021 Report Share Posted May 27, 2021 Following is my Codes: function processOffer(offer) { if(offer.isGlitched() || offer.state === 11) { console.log("This offer is Glitched! decline."); declineOffer(offer); } else if (offer.partner.getSteamID64() === config.trashint) { acceptOffer(offer); } else{ var ourItems = offer.itemsToGive; console.log(ourItems) var theirItems = offer.itemsToReceive; var ourValue = 0 ; var theirValue = 0; for (var i in ourItems) { var item = community.market_hash_name; console.log(item) if(prices[item]) { ourValue += prices[item].sell; } else { console.log("invaild Value."); ourValue += 99999; } } for (var j in ourItems) { var item= community.market_hash_name[j]; console.log(item) if(prices[item]) { theirValue += prices[item].buy; } else { console.log("Their Values was Different."); } } console.log("Our value: "+ ourValue); console.log("Their value:"+ theirValue); if(ourValue <= theirValue) { acceptOffer(offer); } else { declineOffer(offer); } } } When i run it: C:\Users\user\Desktop\steambot\steambot.js:103 var item = community.market_hash_name; ^ TypeError: Cannot read property '0' of undefined what should i change? is it syntax error? Quote Link to comment Share on other sites More sharing options...
Dr. McKay Posted May 27, 2021 Report Share Posted May 27, 2021 You shouldn't use for...in to iterate over arrays. Please research iterating over arrays in JavaScript. Quote Link to comment Share on other sites More sharing options...
_Gala Posted May 27, 2021 Author Report Share Posted May 27, 2021 Thanks for you answer Quote Link to comment Share on other sites More sharing options...
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.