Jump to content

withdraw all items on a list


Lewis

Recommended Posts

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

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

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

 

Send me a message on skype

Edited by Eagle Scripts
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

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.

Link to comment
Share on other sites

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