Jump to content

withdraw all items on a list


Recommended Posts

Posted (edited)

i am looking to withdraw items A, B, C, D, E from the bank for example.

what would be the best way to do this?

 

would i check individually for each item i.e

 

if A is in bank

withdraw A

If B is in bank

withdraw B

etc

 

or would i be able to do a list for example:

 

if Items is in bank

withdraw Items

 

Edit:

 

i want to withdraw ALL not X/all but one etc

Edited by Lewis
Posted (edited)

You could maybe try to loop through the items in a for loop by making a list/array and loop through every item in that list/array

 

could you give me a code example please?

 

ArrayList listTest = new ArrayList(

listTest.add( "first item" );

listTest.add( "second item" );

listTest.add( "third item" );

listTest.add( "fourth item" );

 

for example

Edited by Lewis
Posted

still needing help with this

 

if(getBank().isOpen()){

if (getBank().contains("itemA")) {

 getBank().withdraw("itemA", 5); //Will withdraw 5 of Item A

}

if (getBank().contains("itemB")) {

 getBank().withdrawAll("ItemB"); //will withdraw ALL of Item B

}

if (getBank().contains("itemC")) {

 getBank().withdraw("itemC", 5); //Will withdraw 5 of Item C

}

if (getBank().contains("itemD")) {

 getBank().withdrawAll("ItemD"); //will withdraw ALL of Item D

}

}

 

 

--This might not be the best way but hope it can help!

Posted (edited)

I'd imagine its possible to make a list or array work, but straight up use won't work. 

 

EDIT: Adding in failsafes to what i've written below would be an improvement, if statements like how bamboozled wrote it is a step in the right direction. 

private String items[] = new String[] {"Death rune", "Nature rune", "Battlestaff",  };

bank.withdrawAll(items); // this won't work.

/////////////////////////////////////////////////////////////////////////// This is how i would write it.

getBank().enableMode(Bank.BankMode.WITHDRAW_NOTE);
bank.withdrawAll(A);
new ConditionalSleep(10000) {
	@[member='Override']

	public boolean condition() throws InterruptedException {
		return inventory.contains(A);
	}
}.sleep();
bank.withdrawAll(B);
new ConditionalSleep(10000) {
	@[member='Override']

	public boolean condition() throws InterruptedException {
		return inventory.contains(B);
	}
}.sleep();
bank.withdrawAll(C);
new ConditionalSleep(10000) {
	@[member='Override']

	public boolean condition() throws InterruptedException {
		return inventory.contains(C);
	}
}.sleep();
Edited by PlagueDoctor
Posted

To get you started:

// Google "ArrayList"
List<String> itemNames = new ArrayList<>();

// Add items to ArrayList
itemNames.add("nature rune");
itemNames.add("dragon dagger");

// Use Lambda expressions to loop through list and withdraw items
// (e) is the individual (e)lement of the list
itemNames.forEach((e) -> bank.withdrawAll(e));

There's NO validation in this. It's a simple assumption-based botting; we're assuming we'll be able to withdraw each item.

Posted (edited)

if(getBank().isOpen()){

if (getBank().contains("itemA")) {

 getBank().withdraw("itemA", 5); //Will withdraw 5 of Item A

}

if (getBank().contains("itemB")) {

 getBank().withdrawAll("ItemB"); //will withdraw ALL of Item B only if A is already withdrawn

}

if (getBank().contains("itemC")) {

 getBank().withdraw("itemC", 5); //Will withdraw 5 of Item C only if A and B are already withdrawn.

}

if (getBank().contains("itemD")) {

 getBank().withdrawAll("ItemD"); //will withdraw ALL of Item D only if A,B, and C are already withdrawn.

}

}

 

 

--This might not be the best way but hope it can help!

 

Would be better to do else if instead of just using an if

else if

causes the previous step to become false until it moves onto the next step.

Example:

if (getBank().contains("itemA")) {
 getBank().withdraw("itemA", 5); //Will withdraw 5 of Item A
} else if (getBank().contains("itemB")) {
 getBank().withdrawAll("ItemB"); //will withdraw ALL of Item B
}else if (getBank().contains("itemC")) {
 getBank().withdraw("itemC", 5); //Will withdraw 5 of Item C
}else if (getBank().contains("itemD")) {
 getBank().withdrawAll("ItemD"); //will withdraw ALL of Item D
}
Edited by Juggles
  • Like 1

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