Jump to content


Photo
Question

Is this correct?



  • Please log in to reply
1 reply to this topic

#1 NicoB23

NicoB23

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 15 January 2019 - 02:04 PM

Hello good day, I am new to coding. 

mainClient.on('webSession', function(sessionID, cookies) {

   mainManager.setCookies(cookies, function(err) {
      if (err) { // Handle Error.
         console.log(err);
         process.exit(1); // Exit, if we cannot connect, since we can't do anything.
         return;
      }
      mainManager.getInventoryContents(753, 6, true, function(err, inv) { // Load Inventory
         if (err) { // Handle Error.
            console.log('Error, in loading our inventory.')
            return;
         }
         if (inv.length == 0){
           console.log('Inventory is empty, add some items(cheap ones, like trading cards or gems)')
         }
         var firstOffer = mainManager.createOffer(config.accounts.account2.tradelink); // Intialize Trade Offer
         var itemname = inv[0].market_hash_name.toLowerCase();
         console.log('The item in which we are using is a/an ' + itemname)
         firstOffer.addMyItem(inv[0]);
         firstOffer.setMessage(SECURITY_CODE.toString()); // Set a message, so no one can slip in a trade, and try to steal your items.
         firstOffer.send((err, status) => { // Send offer.
            if (status == 'pending') { // Check if it needs to be confirmed.
               mainCommunity.acceptConfirmationForObject(config.accounts.account1.identity_secret, firstOffer.id, function(err) { // Try to accept Trade
                  if (err) { // Handle, any accepting errors.
                     console.log('Error accepting Trade.');
                     return;
                  } else { // It worked fine, Now the farm begins.
                     console.log('Trade offered. Counter is at : ' + counter);
                  }
               });
            }
         });
      });
   });
   // Set Cookies.
   mainCommunity.setCookies(cookies);
});
 
 
If one of the err fails, It cannot return to first. I mean is it stock like example " Error accepting Trade" . Like that. I just want to return until it goes to console.log('Trade offered. Counter is at : ' + counter);. 
Thank you for the help. 

Attached Files



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,074 posts

Posted 17 January 2019 - 05:20 AM

That looks correct.







Also tagged with one or more of these keywords: Question

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users