Jump to content

can't get acceptTrade() to work


Tylersbored

Recommended Posts

I am trying to make my mule accept a trade but for some reason, he wont execute the command, or nothing happens when he executes the command. I can confirm that he is in the first trade window. This command works for my other scripts but for some reason in this script it wont work. I am checking the log and "Accepting Trade" keeps looping so I know that it keeps trying to execute the command. Thanks for the help.UOSRi8I.png

edit: I put this.script.trade.acceptTrade() in an if statement to see if it was returning true but it is returning false. Still not sure why it is returning false though.

edit2: When the bot attempts to accept trade, the mouse hovers over "decline".. 

Edited by Tylersbored
Link to comment
Share on other sites

14 minutes ago, Tylersbored said:

I am trying to make my mule accept a trade but for some reason, he wont execute the command, or nothing happens when he executes the command. I can confirm that he is in the first trade window. This command works for my other scripts but for some reason in this script it wont work. I am checking the log and "Accepting Trade" keeps looping so I know that it keeps trying to execute the command. Thanks for the help.UOSRi8I.png

edit: I put this.script.trade.acceptTrade() in an if statement to see if it was returning true but it is returning false. Still not sure why it is returning false though.

Why are you using while loops? Firstly the script is already looping, (the method is even called onLoop) and you also only want to be offering items and accepting trade once.

Your code should be structured more like:

If not in trade with player then trade player

Else if first window and not offered coins then offer coins

Else if not accepted trade window accept trade window

Edited by Explv
Link to comment
Share on other sites

4 minutes ago, Explv said:

Why are you using while loops? Firstly the script is already looping, (the method is even called onLoop) and you also only want to be offering items and accepting trade once.

Your code should be structured more like:

If not in trade with player then trade player

Else if not accepted trade window accept trade window

can u write me the code plz

Link to comment
Share on other sites

15 minutes ago, Explv said:

Why are you using while loops? Firstly the script is already looping, (the method is even called onLoop) and you also only want to be offering items and accepting trade once.

Your code should be structured more like:

If not in trade with player then trade player

Else if first window and not offered coins then offer coins

Else if not accepted trade window accept trade window

Ah I see. I just started writing scripts about a week ago so sorry for the spaghetti code haha. Anyways, I restructured my code to your advice and it seems to be working now, thanks!aJnXchX.png

Link to comment
Share on other sites

5 minutes ago, Tylersbored said:

Ah I see. I just started writing scripts about a week ago so sorry for the spaghetti code haha. Anyways, I restructured my code to your advice and it seems to be working now, thanks!aJnXchX.png

Also, those static sleeps on every second line are pretty obsolete. You could throw in more cond sleeps, though.

Link to comment
Share on other sites

50 minutes ago, Tylersbored said:

Ah I see. I just started writing scripts about a week ago so sorry for the spaghetti code haha. Anyways, I restructured my code to your advice and it seems to be working now, thanks!aJnXchX.png

In my opinion, it should be more like:

if not is currently trading:
    if interact "Trade with" on worker is successful:
        Conditional sleep until is currently trading
else if not my offer contains coins:
    if enter amount dialog is visible:
        type 35k
    else if interact "Offer-x" on "Coins" is successful:
        Conditional sleep until enter amount dialog is visible
else if not accepted trade:
    accept trade

Interactions can fail, so you shouldn't continue with other interactions unless you know the first one succeeded. For example, in your code you type 35k after interacting with the Coins, but the Coin interaction might fail (it probably won't), and your bot will just type 35k into the chatbox.

Edited by Explv
Link to comment
Share on other sites

1 hour ago, Explv said:

In my opinion, it should be more like:


if not is currently trading:
    if interact "Trade with" on worker is successful:
        Conditional sleep until is currently trading
else if not my offer contains coins:
    if enter amount dialog is visible:
        type 35k
    else if interact "Offer-x" on "Coins" is successful:
        Conditional sleep until enter amount dialog is visible
else if not accepted trade:
    accept trade

Interactions can fail, so you shouldn't continue with other interactions unless you know the first one succeeded. For example, in your code you type 35k after interacting with the Coins, but the Coin interaction might fail (it probably won't), and your bot will just type 35k into the chatbox.

Oh wow. That structure looks alot better.. Thank you so much man, I'll try to follow this principle from now on. Time to go change all my code rip.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...