Jump to content
McKay Development

Recommended Posts

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. :wacko:

Whay I'm missing? Did I need something more to make it work?

 

Thanks for reading me and have a nice day! :)

Link to comment
Share on other sites

 

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? :huh:

 

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? :blink:

 

Thanks you for reading meSunriseM and Dr. McKay! You are so nice! :D

Link to comment
Share on other sites

I'm not on my PC right now for make some tests before asking, but... how can I accept them first? :huh:

 

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? :blink:

 

Thanks you for reading meSunriseM and Dr. McKay! You are so nice! :D

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");
         }

     }
});
Link to comment
Share on other sites

 

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 :D :D

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...