Jump to content

Cant get bot to bank + withdraw food


trickked

Recommended Posts

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;

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites

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
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.
Note: Your post will require moderator approval before it will be visible.

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.

  • Recently Browsing   0 members

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