Jump to content
McKay Development

adma

Member
  • Posts

    23
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Australia
  • Interests
    Something something food.
  1. Next time, please present properly formatted code with curly braces... its very disorientating to follow if .. else statements that do not use curly brackets...
  2. I don't know what you are trying to do with the comma operator, but by the looks of it you want to use the and operator (&&) in your if (onlyKeys, onlyRef) checks... if (onlyKeys2, onlyRef2) âž¡ if (onlyKeys2 && onlyRef2) In regards to your declining offer thing... its probably to do with your lack of curly braces surrounding if and else e.g if (x && y) { // code } else { // code } Not ... if (x && y) // code else // code What do these lines do/mean? 'refAmount = offer.itemsToGive.length == keyAmount * buyprice' 'refAmount = offer.itemsToReceive.length == keyAmount * sellprice' Also, unless you want the refAmount and keyAmount to be global, you should really declare them with var ... keyAmount = offer.itemsToGive.length âž¡ var keyAmount = offer.itemsToGive.length Even though I am new to coding/scripting and I can see your code is very untidy/messy... PS: What is offers.on('newOffer') ? and why is trade offer manager newOffer listener nested inside this???
  3. manager.on("newOffer", function(offer) { var onlyKeys = (offer.itemsToReceive.every(function(item) { return item.name == "Mann Co. Supply Crate Key"; })); if (onlyKeys) { keyAmount = offer.itemsToReceive.length console.log("Received trade offer containing " + keyAmount + " keys, accepting"); offer.accept(function(err) { if (err) console.log(err); }); } else { console.log("Trade offer contains non key items. Declining"); offer.decline(function(err) { if (err) console.log(err); }); } }
  4. var keys = offer.itemsToReceive.map { if (item.name == "Mann Co. Supply Crate Key") { return item; } } var keyAmount = keys.length Something like that should work, and is handy if you wanted to send keys ... you could also do something like var keyAmount = 0; offer.itemsToReceive.forEach(function(item) { if (item.name == "Mann Co. Supply Crate Key") { keyAmount++; } } // do something with keyAmount
  5. If you want to get the market hash names of each item you're giving, you would probably use forEach or a for loop to cycle through the itemsToGive array ... e.g manager.on('newOffer', function(offer) { offer.itemsToGive.forEach(function(item) { console.log("Item to give : " + item.market_hash_name); // Items to give: Chroma 2 Case }); }); a for ... of loop (edited from for..in loop) manager.on('newOffer', function(offer) { for (var item of offer.itemsToGive) { console.log("Items to give : " + item.market_hash_name); // Items to give: Chroma 2 Case } }); a regular for loop manager.on('newOffer', function(offer) { for (var i = 0; i < offer.itemsToGive.length; i++) { console.log("Items to give #" + i + " : " + offer.itemsToGive[i].market_hash_name); // Items to give #1 : Chroma 2 Case } });Same deal will apply for itemsToReceive ... or any other array you wanted to cycle through read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration
  6. Anyway, for the time being I will use offer.data to do something like offer.data('accepted', 'true') when a trade offer is accepted, and then just do a check for true on realTimeTradeCompleted
  7. Hi McKay, I found some time to fiddle around and try to remake the scenario. \ info: [tradeStarted] Started real time trade info: Ended real trade due to pending info: Offer pending with trade offer 1543634806 info: [newOffer] Received trade offer 1543634806 info: [30 seconds after receiving trade offer 1543634806] warn: Trade offer 1543634806 state : Active I'm sure when accepting this offer, realTimeTradeCompleted will emit. Right now the TF2 / Steam / whatever services are being slow and giving lots of Error 28's and 'Data Temporarily Unavailable' ... I'll edit this post when it works. edit... eventually accepted it. info: [realTimeTradeCompleted] Real time trade 1543634806 completed warn: [realTimeTradeCompleted] Real time trade 1543634806 state : Accepted info: Received trade offer 1543634806 changed from 2 to 3
  8. It seems I can't reproduce this behavior anymore, but I can tell you that it occurred when http://steamstat.us reported the TF2 API as being 'slow' I'll keep trying and see what I can find.
  9. Yes, this is happening through real time trading requested by me to the bot through Steam chat. And I made a mistake in my previous post, the bot does not decline the offer, the bot ignores it.
  10. Yes. I'll break it down so we both don't get confused ... I will be 'user' , bot will be 'bot' This is what initially happened when bot accepts trade offer regardless of realTimeTrade, User trades bot and gives 1 key to bot User confirms mobile confirmation Bot emits 'newOffer' event (from the real time trade) Bot then accepts trade offer from 'newOffer', then does 'functions' Bot emits 'realTimeTradeCompleted', then does 'functions' Conclusion, bot does 'functions' twice from one real time tradeThis is what happened when bot does ignores trade offers that are realTimeTrade (ie. manager.newOffer .... if (!offer.realTimeTrade) { carry out 'functions' }) User trades bot and gives 1 key to bot User confirms mobile confirmation Bot emits 'newOffer' event (from the real time trade) Bot does nothing with the trade from 'newOffer' because it is a realTimeTrade, so 'functions' aren't carried out Bot does not emit 'realTimeTradeCompleted' because trade offer from 'newOffer' isn't accepted Conclusion, bot does not carry out 'functions'I hope I'm making sense
  11. When I didn't accept it, realTimeTradeCompleted didn't emit. {"level":"warn","message":"Received trade offer 1541120781 from real trade, ignoring","timestamp":"2016-09-26T22:45:21.723Z"} {"level":"info","message":"Received trade offer 1541120781 changed from 2 to 6","timestamp":"2016-09-26T23:07:22.553Z"} // I cancelled the trade offer ~20 minutes after
  12. To mobile confirm you have to use steam-community newConfirmation event community.on("newConfirmation", function(conf) { var time = Math.floor(Date.now() / 1000); conf.respond(time, SteamTotp.getConfirmationKey(PLACEYOURCONFKEYHERE, time, "allow"), true, function(err) { if (err) { // error } else { // anything you want to do when you mobile confirm } }); });
  13. Well you see, in my original post for some reason the real time trade emitted the newOffer , as in it made a trade offer from the real trade. info: Received new trade offer from adma [U:1:94759074] // Bot receives trade offer (newOffer) info: Attempting to accept trade offer 1539324331 // Bot attempts to accept it info: Accepted trade offer 1539324331 containing 1 keys // Accepts it info: Real time trade offer 1539324331 completed // After accepting the trade offer, realTimeTradeCompleted is emitted This was generated from a real time trade where I gave the bot 1 key. When I did what you said in your previous post, the bot ignored the trade offer because it was from a realTimeTrade, and consequently left the trade offer just sitting there. For some odd reason an actual trade offer (that requires the bot to accept it) was made from the real time trade. {"level":"info","message":"Started trade with adma [U:1:94759074]","timestamp":"2016-09-26T22:43:41.250Z"} {"level":"info","message":"Ended real trade due to pending","timestamp":"2016-09-26T22:44:07.576Z"} {"level":"info","message":"Offer pending with trade offer 1541120781","timestamp":"2016-09-26T22:44:07.577Z"} {"level":"warn","message":"Received trade offer 1541120781 from real trade, ignoring","timestamp":"2016-09-26T22:45:21.723Z"} // this is newOffer I have messed around with it and can't seem to reproduce it anymore after passing a node-steam-user instance to the trade offer manager. Don't know if thats what fixed it.
×
×
  • Create New...