Jump to content

How to check amount of coins in inventory?


Recommended Posts

Posted (edited)

SOLVED THANKES TO

Juggles

__________________________________________________________________________________________________________

I'm making a script that involves checking the amount of coins a player has in their inventory.

 

At the moment it doesn't do anything. It doesn't even open the bank.

Here is my code

case BANK:
    if (!getBank().isOpen()){
        getBank().open();
    } else if (inventory.getAmount("Coins") < 500) {
        getBank().withdrawAll("Coins");
    } else {
        getBank().close();
    }
break;

It's pretty similar to this, so I'm not sure what I'm doing wrong.

http://osbot.org/forum/topic/68196-get-the-amount-of-items-in-inventory/

 

Thanks.

Edited by Lexhanatin
  • Like 1
Posted

I'm making a script that involves checking the amount of coins a player has in their inventory.

 

At the moment it doesn't do anything. It doesn't even open the bank.

Here is my code

case BANK:
    // If inventory contains less than 500 coins, withdraw coins
    if (inventory.getAmount("Coins") < 500) {
        getBank().withdrawAll("Coins");
    } else {
        getBank().close();
    }
break;

It's pretty similar to this, so I'm not sure what I'm doing wrong.

http://osbot.org/forum/topic/68196-get-the-amount-of-items-in-inventory/

 

Thanks.

 

You need to open the bank first.

if (getBank() == null) {
    // walk to bank
} else if (!getBank().isOpen()) {
    if (getBank().open()) {
        new ConditionalSleep(5000) {
            @ Override
            public boolean condition() throws InterruptedException {
                return getBank().isOpen();
            }
        }.sleep();
    }
} else {
    getBank().withdrawAll("Coins");
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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