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.

how to define If then no items left

Featured Replies

Hello,

 

How should i define the "if" statement for finishing my script ? It should finish then there is no specific item in the bank. So then that condition is met, it will go to a state that will stop the script / logout.

private State getState() {
Item something = bank.getItem("specific item");
if (something == null) 
return State.FINISHED;

if (something.getAmount() == 0)
return State.FINISHED;

case FINISHED:
stop();
logoutTab.logOut();
break;

So i tried 2 different ways, yet what happens is : i start the script and the condition for it is met and it just do the stuff in FINISHED state.

 

This is my first script, so im not used to the osbot api and not sure how some method works.

Hopefully thats your problem 

private State getState() {
Item something = bank.getItem("specific item");
if (something == null) 
return State.FINISHED;
}


 

private State onLoop() {
case FINISHED:
if (something.getAmount() == 0){
stop();
logoutTab.logOut();
}
break;

 

Edited by Ispecyou

Hi, I see you are Lithuanian so if you got any problems you could ask me, I could help you in your native toungue :)

And I think do as @Ispecyou told.

  • Author

I tried to do as Ispecyou showed, yet it looks like my client freezes then i try to use .getAmount() method. I can see people walking arround, yet i cannot stop the script, nor exit the client, the only way to exit is to kill process.

private State getState() {
Item something = bank.getItem("specific item");
boolean something = bank.contains("specific item");
}

These 2 lines in getState() will return null or false not sure why it is like that.

 

But it works if i start the script while bank is open.

private State getState() {
boolean something = bank.contains("specific item");
if (!something) 
return State.FINISHED;
}

Yet, im quite confused why it does not get the correct value while bank is closed.

Item something = bank.getItem("specific item");

Maybe there is another better way of doing it ? Not necessary according to what i have ? - no specific item left in bank -> go to state.

Its because you are checking if something is in bank, when the bank isnt oppend.

 

So first make the script check if the bank is opped if so then check if bank cointains item.

 

Create an account or sign in to comment

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.