Jump to content

How to check amount of coins in inventory?


Lexhanatin
 Share

Recommended Posts

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
Link to comment
Share on other sites

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");
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

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