Mr Game and Watch Posted May 1, 2017 Report Posted May 1, 2017 Hello! I'm still on my challenge to avoid SteamApp (My Android device is quite bad, I know).Well. I'm trying to make a system for accept or decline manually incoming offers. I made the following code: manager.getOffers(1,function(err, sent, recived){ if (err) { console.log(err); } else { for (var i = 0; i < recived.length; i++) { if(recived[i].id == trade_I_want_to_decline){ recived[i].cancel(function(err) { if (err) { console.log(err.message); } else { console.log("Horray! trade declined!") } }); } } } }); //... Other unrelated code //... More unrelated code manager.getOffers(1,function(err, sent, recived){ if (err) { console.log(err); } else { for (var i = 0; i < recived.length; i++) { if(recived[i].id == trade_I_want_to_accept){ recived[i].accept(function(err) { if (err) { console.log(err.message); } else { console.log("Horray! Trade accepted!") } }); } } } }); Well. These are separated functions. As you can see, they are basically the same except the main function: Accept and Decline. Decline works like a charm. But accept... doesnt work well. In fact, it returns the "Horray! Trade accepted!" message, but it doesn't really accept the trade. Whay I'm missing? Did I need something more to make it work? Thanks for reading me and have a nice day! Quote
SunriseM Posted May 1, 2017 Report Posted May 1, 2017 I see that you are not confirming the offer. Are you using Steam-Community startConfirmationChecker method? Quote
Mr Game and Watch Posted May 2, 2017 Author Report Posted May 2, 2017 I see that you are not confirming the offer. Are you using Steam-Community startConfirmationChecker method? I think I don't. That method always confirm all the offers? Because if that is true, then I might get in trouble. I just want to accept 1 offer... maybe one guy send me a fishy one and get all my items Quote
Dr. McKay Posted May 2, 2017 Report Posted May 2, 2017 It will only (mobile) confirm offers you already accepted. That said, I highly discourage using the confirmation checker. Just use acceptConfirmationForObject as needed (after accepting offers). Quote
Mr Game and Watch Posted May 2, 2017 Author Report Posted May 2, 2017 Just use acceptConfirmationForObject as needed (after accepting offers) I'm not on my PC right now for make some tests before asking, but... how can I accept them first? I mean, for example, when I send one I use createOffer and then I use "send" before I use "acceptConfirmationForObject", but how can I accept first the trade? Like I put on my first comment code? Or it's completely different? Thanks you for reading meSunriseM and Dr. McKay! You are so nice! Quote
SunriseM Posted May 2, 2017 Report Posted May 2, 2017 I'm not on my PC right now for make some tests before asking, but... how can I accept them first? I mean, for example, when I send one I use createOffer and then I use "send" before I use "acceptConfirmationForObject", but how can I accept first the trade? Like I put on my first comment code? Or it's completely different? Thanks you for reading meSunriseM and Dr. McKay! You are so nice! Here some help. recived[i].accept(function(err, status) { //Accept the offer and wait for callback err or status if (err) { console.log(err.message); } else { if(status === "pending"){ //Offer needs confirmation. use acceptConfirmationForObject() . recived[i].id is the id that you need to accept } else { //Offer doesn't needs confirmation. console.log("Hooray. Trade Offer Accepted"); } } }); Quote
Mr Game and Watch Posted May 2, 2017 Author Report Posted May 2, 2017 Here some help. recived[i].accept(function(err, status) { //Accept the offer and wait for callback err or status if (err) { console.log(err.message); } else { if(status === "pending"){ //Offer needs confirmation. use acceptConfirmationForObject() . recived[i].id is the id that you need to accept } else { //Offer doesn't needs confirmation. console.log("Hooray. Trade Offer Accepted"); } } }); Yes! Now it works! thank you so much for your help! And also thanks to Dr. Mckay for all the prevous posts! :D Quote
Dr. McKay Posted May 2, 2017 Report Posted May 2, 2017 recived may no longer be valid inside of that callback, as i would have changed on the next loop iteration (welcome to closures!). If you use recived.forEach it will work as expected. Quote
Mr Game and Watch Posted May 3, 2017 Author Report Posted May 3, 2017 Well, I used "trade_I_want_to_accept" instead of recived[i] as, like you said, was no longer valid.Thanks again! 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.