Jump to content

Cant get bot to bank + withdraw food


Recommended Posts

Posted

This is what i have:

 

 private State getState() {
        int HpPercent = (getSkills().getDynamic(Skill.HITPOINTS) * 100/getSkills().getStatic(Skill.HITPOINTS));
        NPC farmer = getNpcs().closest("Master Farmer");
        if (getInventory().isFull())
            return State.BANK;

case BANK:
            log("Bank");
            if(inventory.isFull() && !getInventory().contains("Lobster")) {
                NPC user = getNpcs().closest("Banker");
                getNpcs().closest("Banker").interact("Bank");
                user.interact("Bank");
                getBank().getItem("Lobster");
            }
 break;

Posted

I'm not really sure what you're trying to do with the code you have, I think you've misunderstood the idea behind some of the API methods and you might need to brush up a little on your general java understanding, however I think this should help:

case BANK:
    if (getBank().isOpen()) {
      getBank().withdraw("Lobster", 28);
    } else {
      NPC banker = getNpcs().closest("Banker");
      if (banker != null && banker.exists()) {
        banker.interact("Bank");
        sleep(2000); // Put a conditional sleep here!
      } else {
        stop(); // Stop if banker could not be found. You will probably need to add walking here
      }
    }
	break;

The code that i've given you above is very generalised and needs modifications, but it should hopefully be a good starting point for getting your code to do something!

-Apa

  • Like 3
Posted
Just now, Apaec said:

I'm not really sure what you're trying to do with the code you have, I think you've misunderstood the idea behind some of the API methods and you might need to brush up a little on your general java understanding, however I think this should help:


case BANK:
    if (getBank().isOpen()) {
      getBank().withdraw("Lobster", 28);
    } else {
      NPC banker = getNpcs().closest("Banker");
      if (banker != null && banker.exists()) {
        banker.interact("Bank");
        sleep(2000); // Put a conditional sleep here!
      } else {
        stop(); // Stop if banker could not be found. You will probably need to add walking here
      }
    }
	break;

The code that i've given you above is very generalised and needs modifications, but it should hopefully be a good starting point for getting your code to do something!

-Apa

Thanks bud. much appreciated

Posted (edited)

Does this even compile?

 if(inventory.isFull() && !getInventory().contains("Lobster")) {

this check if your inventory is Full and if it doens't contain a lobster, though nowhere later it deposits the stuff.

Try something like 

if (inventory.isFull()) {
  if (!bank.isOpen()) {
    NPC banker = getNpcs().closest("Banker");
    if (banker != null) {
      banker.interact("Bank");
   } else {
    bank.depositAll();
    bank.withdraw("Lobster", 1);
   bank.close();
  }
}
	

Add some sleeps in between and etc. Check if you're in the banking area, check your conditions when to bank and etc

Edited by nosepicker
  • Like 2

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