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.

inventory.GetAmount("Coins") bugging occasionally

Featured Replies

Hey All :) Inb4 all the "Why is the bot down" posts.

 

My question has to do with the inventory.GetAmount("Coins") statement and why some times the below getState() method sometimes returns State.A

 

Usually inventory.GetAmount("Coins") returns the correct amount, however lately when the computer lags a little it returns 0. It happens occasionally on my windows vm, but on my Linux VPS as well (and more often) that I notice has more graphical lag than my windows (but it could just be the VNC connection). 

 

I dont want to put a "&& !=0" check for the .getAmount function because it is possible that the function could return 0 and this isnt great practice in general.

 

Does everyone use this method? Has anyone run into this error before? 

if(inventory.getAmount("Coins") < 8000){
    return State.A;
}else if(inventory.isFull() || myPlayer().isUnderAttack()){
    return State.B;
}else{
    return State.C;
}

Hey All :) Inb4 all the "Why is the bot down" posts.

My question has to do with the inventory.GetAmount("Coins") statement and why some times the below getState() method sometimes returns State.A

Usually inventory.GetAmount("Coins") returns the correct amount, however lately when the computer lags a little it returns 0. It happens occasionally on my windows vm, but on my Linux VPS as well (and more often) that I notice has more graphical lag than my windows (but it could just be the VNC connection).

I dont want to put a "&& !=0" check for the .getAmount function because it is possible that the function could return 0 and this isnt great practice in general.

Does everyone use this method? Has anyone run into this error before?

if(inventory.getAmount("Coins") < 8000){    return State.A;}else if(inventory.isFull() || myPlayer().isUnderAttack()){    return State.B;}else{    return State.C;}
Where are you calling this method? Just to make sure you aren't doing something incorrect?

If you aren't then you should file a bug report

Edited by Explv

  • Author

Where are you calling this method? Just to make sure you aren't doing something incorrect?

If you aren't then you should file a bug report

 

I'm calling this method so that when I dont have enough money to buy from the shop any more it trades mule. Yea I think bug report may need to happen. Just wanted to get some input first. Thanks for the reply!

I'm calling this method so that when I dont have enough money to buy from the shop any more it trades mule. Yea I think bug report may need to happen. Just wanted to get some input first. Thanks for the reply!

I meant where in your code are you calling your getState() method

  • Author

Ah sorry. Here is my loop()

@[member='Override']
public int onLoop() throws InterruptedException {
    switch (getState()) {
    case A:
        log("State A");
        break;
    case B:
        log("State B");
        break;
    case C:
        log("State C");
        break;
    }

    return random(200,500);
} 

Edited by k9thebeast

Ah sorry. Here is my loop()

@[member='Override']public int onLoop() throws InterruptedException {    switch (getState()) {    case A:        log("State A");        break;    case B:        log("State B");        break;    case C:        log("State C");        break;    }    return random(200,500);}

Ok looks fine as far as I can see

I assume you are hopping a lot because you mentioned store buying.

The inventory returns null or empty sometimes as a result of the loading screen.

 

I recommend adding 

 

if (getClient().getLoginState() == LoginState.LOADING || getClient().getLoginState() == LoginState.LOADING_MAP) {
return 300;
}

To your loop :)

  • Author

I assume you are hopping a lot because you mentioned store buying.

The inventory returns null or empty sometimes as a result of the loading screen.

 

I recommend adding 

 

if (getClient().getLoginState() == LoginState.LOADING || getClient().getLoginState() == LoginState.LOADING_MAP) {
return 300;
}

To your loop smile.png

Thank you sir I'll give it a go!

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.