Jump to content
McKay Development

Recommended Posts

Posted

To make interactions with bots and alts easier, I wanted to get an autoaccept-script going, that simply accepts everything where the itemstogive.length ==0.

 

This is my code:

 

manager.on('newOffer'function (offer) {

    accept(offer);


});

function accept(offer) {
    if (offer.itemsToGive.length == 0) {
        offer.accept(truefunction (err) {
            console.log("offer.State: " + offer.state);
            if (err) {
                console.log("error: " + err);
                console.log("offer.State: " + offer.state);

                if (!(offer.state == 3 || offer.state == 6 || offer.state == 8)) {
                    setTimeout(accept(offer), 3000);
                    return;
                }
            }
           });

 

 

Sometimes just nothing happens, and the offer gets ignored completely. My guess is, that the trade-offer is buggy at the beginning (no items show on both sides), and that offer.itemstogive.length is undefined then, and my if is never true? Its quite hard to debug it for me, since this "error-case" isn't really reproduceable since it happens just very rarely.

Posted

My guess is, that the trade-offer is buggy at the beginning (no items show on both sides), and that offer.itemstogive.length is undefined then, and my if is never true?

 

That's certainly a possibility.

Posted

That's certainly a possibility.

After some testing, I figured out the following behavior today: My assumption is not the reason. When this problem happens, the callback of offer.accept never gets executed. And when it happens, all the upcoming offers don't get accepted aswell. I changed the code a bit, here it is: 

 

//new tradeoffer
manager.on('newOffer'function (offer) {

    accept(offer);

 

});

function accept(offer) {
    console.log("Attempting to accept offer...");
    console.log("Items to give Length: " + offer.itemsToGive.length);
    console.log("offer.state: " + offer.state);
    if (offer.itemsToGive.length == 0) {
        offer.accept(falsefunction (err) {
            console.log("offer.State: " + offer.state);
            if (err) {
                console.log("error: " + err);
                console.log("offer.State: " + offer.state);
            }
            if (!(offer.state == 3 || offer.state == 6 || offer.state == 8)) {
                console.log("recursive attempt...");
                setTimeout(accept(offer), 3000);
                return;
            }

            console.log("\n");
        });
      
    }

 

}

 

everything gets printed all the time except the stuff that is contained inside the callback of offer.accept(...)(Not even the first line). My Question here is: Is my code just stupid / did I do a thinking error, or is it problematic when I am logged into that account from browser and phone at the same time and do things there aswell?

 

Also, one thing that I forgot: When I restart that code in the console, It works fine again.

  • 2 weeks later...
Posted

I solved it. I forgot to add:

client.on('webSession', function(sessionID, cookies) {
    manager.setCookies(cookies, function(err) {
        if (err) {
            console.log(err);
            process.exit(1); // Fatal error since we couldn't get our API key
            return;
        }

        console.log("Got API key: " + manager.apiKey);
    });
});

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