Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

can't get acceptTrade() to work

Featured Replies

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

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

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

  • Author
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

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.

  • Author
10 minutes ago, Container said:

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

So should I be using a bunch of conditional sleeps instead of static sleeps? 

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

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

1 hour ago, Tylersbored said:

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.

This won't be the last time you have to change major parts of any code :boge:

1 minute ago, Container said:

This won't be the last time you have to change major parts of any code :boge:

xD

2 minutes ago, DrDu said:

xD

postCount += 1; :???:

10 minutes ago, Container said:

postCount += 1; :???:

:doge:                  :doge: :doge: :doge:      :doge:

:doge:                  :doge:        :doge:      :doge:

:doge: :doge: :doge:     :doge: :doge: :doge:      :doge: :doge: :doge:

  • Author
15 minutes ago, Container said:

This won't be the last time you have to change major parts of any code :boge:

Definitely not haha. I learn as I go

6 minutes ago, Tylersbored said:

Definitely not haha. I learn as I go

its a never ending experience rofl

I'm not sure if this is still the case but a month or two ago when I was testing acceptTrade() I realised the widgets are wrong. So I had to find what widgets to interact with myself using the widget debugger.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.