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

Who can fix my code?

Featured Replies

Hello guys. Been working hard on an automatic trading script and after alot of figgeling I'm currently hitting a wall.

The idea of the code below is that I want to check what a player is offering, and specifically if he's offering coins. This can be the only thing he's allowed to offer and has to be over a certain value. What I tried to do is wait until the player is offering coins by using a conditional sleep. The first problem is that if the condition is false, it will exit the loop and start over again while it actually needs to decline the trade after nothing has happened for X amount of seconds. Second problem is that I need to check the amount of coins and if it is more than 9. In the current code it will first check for coins and only then it will check for value (which probably isn't properly executes and have no idea how to). So their offer should be placed twice in order for it to register and the code needs to be able to do it on the first check. Here my code:

public int onLoop() throws InterruptedException {
				if (trade.isFirstInterfaceOpen()) {
					if (!trade.getTheirOffers().contains("Coins")) {
						new ConditionalSleep(10000) {
							@Override
							public boolean condition() {
								return trade.getTheirOffers().contains("Coins");
							}
						}.sleep();

						Item item = trade.getTheirOffers().getItem("Coins");
						int amountcoins = item.getAmount();
						log(amountcoins);
					} else {
						
					}

					if (trade.getTheirOffers().contains("Coins") && amountcoins > 9) {
						new ConditionalSleep(10000) {
							public boolean condition() {
								return trade.didOtherAcceptTrade();
							}
						}.sleep();
						if (trade.didOtherAcceptTrade()) {
							trade.acceptTrade();
						} else {
							trade.declineTrade();
						}
					}

As always, help will be much appreciated!

Try overriding your 2nd conditional sleep like so 

new ConditionalSleep(10000) {
    @Override
    public boolean condition() {
    	return trade.didOtherAcceptTrade();
    }
}.sleep();

May be something else wrong with it, let me know.

Edit:

Nesting your third if statement inside your second one may get rid of some problems aswell, you won't need to use a variable for the coins this way, could just say: 

if(getTrade().getTheirOffers().getAmount("Coins") >= 9) {
	// Do stuff
}

 

Edited by naaiz

15 minutes ago, naaiz said:

Try overriding your 2nd conditional sleep like so 


new ConditionalSleep(10000) {
    @Override
    public boolean condition() {
    	return trade.didOtherAcceptTrade();
    }
}.sleep();

May be something else wrong with it, let me know.

Edit:

Nesting your third if statement inside your second one may get rid of some problems aswell, you won't need to use a variable for the coins this way, could just say: 


if(getTrade().getTheirOffers().getAmount("Coins") >= 9) {
	// Do stuff
}

 

@Override is just an annotation. It improves readability and helps compiler checks, but is not essential.

9 minutes ago, Explv said:

@Override is just an annotation. It improves readability and helps compiler checks, but is not essential.

TIL, cheers.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.