Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

if player is in closest bank

Featured Replies

looking for my script to run to the closest bank, but i dont know how to get if closest bank contains myplayer

 

code is:

private final Area[] BANKS = { (Banks.DRAYNOR),
		    (Banks.AL_KHARID),
		    (Banks.LUMBRIDGE_UPPER),
		    (Banks.FALADOR_EAST),
		    (Banks.FALADOR_WEST),
		    (Banks.FALADOR_EAST),
		    (Banks.VARROCK_WEST),
		    (Banks.CAMELOT),
		    (Banks.CATHERBY),
		    (Banks.EDGEVILLE),
		    (Banks.YANILLE),
		    (Banks.GNOME_STRONGHOLD),
		    (Banks.ARDOUGNE_NORTH),
		    (Banks.ARDOUGNE_SOUTH),
		    (Banks.CASTLE_WARS),
		    (Banks.DUEL_ARENA),
		    (Banks.PEST_CONTROL),
		    (Banks.CANIFIS),
		    (Banks.TZHAAR)}; 

&&
 
if (!BANKS.contains(myPlayer())) {
				walking.webWalk(BANKS);
				sleep(random(250, 300));
			

Edited by Lewis

 


make a webwalk event and throw all the banks into the webwalk event and it'll walk to the closest one

 

(this is the solution for walking to the closest bank)

		List<Area> closestArea = new ArrayList<Area>();
		
		closestArea.add(Banks.AL_KHARID);
		
		closestArea.sort(new Comparator<Area>() {
			public int compare(Area entry1, Area entry2) {
				return entry1.getRandomPosition().distance(myPlayer()) - entry2.getRandomPosition().distance(myPlayer());
			}
		});
		getWalking().webWalk(closestArea.get(0));
		
		if(!closestArea.get(0).contains(myPlayer())
		    getWalking().webWalk(closestArea.get(0));

here you go man, just add more banks to the ArrayList

 

closestArea.get(0) returns the closest area.

Edited by Vilius

 

looking for my script to run to the closest bank, but i dont know how to get if closest bank contains myplayer

 

code is:

private final Area[] BANKS = { (Banks.DRAYNOR),
		    (Banks.AL_KHARID),
		    (Banks.LUMBRIDGE_UPPER),
		    (Banks.FALADOR_EAST),
		    (Banks.FALADOR_WEST),
		    (Banks.FALADOR_EAST),
		    (Banks.VARROCK_WEST),
		    (Banks.CAMELOT),
		    (Banks.CATHERBY),
		    (Banks.EDGEVILLE),
		    (Banks.YANILLE),
		    (Banks.GNOME_STRONGHOLD),
		    (Banks.ARDOUGNE_NORTH),
		    (Banks.ARDOUGNE_SOUTH),
		    (Banks.CASTLE_WARS),
		    (Banks.DUEL_ARENA),
		    (Banks.PEST_CONTROL),
		    (Banks.CANIFIS),
		    (Banks.TZHAAR)}; 

&&
 
if (!BANKS.contains(myPlayer())) {
				walking.webWalk(BANKS);
				sleep(random(250, 300));
			

 

Consider reading this tutorial on Arrays: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Edited by Explv

  • Author

 

make a webwalk event and throw all the banks into the webwalk event and it'll walk to the closest one

 

(this is the solution for walking to the closest bank)

 

need to figure out how to return true if for example:

GE is closest, bank, it walks to ge // i got working

then

if GE contains myplayer { 

w.e

 

*GE will be closest bank

need to figure out how to return true if for example:

GE is closest, bank, it walks to ge // i got working

then

if GE contains myplayer { 

w.e

 

*GE will be closest bank

 

All you need to do is check if any of the Areas in the Area[] contain your Position.

 

I'll give you a hint, you might want to use a for loop: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/for.html

  • Author

Doesn't seem like you saw my post. 

List<Area> closestArea = new ArrayList<Area>();
		
		closestArea.add(Banks.AL_KHARID);
		closestArea.add(Banks.DRAYNOR);
		closestArea.add(Banks.VARROCK_WEST);

		closestArea.sort(new Comparator<Area>() {
			public int compare(Area entry1, Area entry2) {
				return entry1.getRandomPosition().distance(myPlayer()) entry2.getRandomPosition().distance(myPlayer());
			}
		});
		getWalking().webWalk(closestArea.get(0));
		
		if(!closestArea.get(0).contains(myPlayer())
		    getWalking().webWalk(closestArea.get(0));

just add more closestArea.add(Banks.DRAYNOR); ?

or do i need to add, entry 1,2,3,4 etc also?

Edited by Lewis

List<Area> closestArea = new ArrayList<Area>();
		
		closestArea.add(Banks.AL_KHARID);
		closestArea.add(Banks.DRAYNOR);
		closestArea.add(Banks.VARROCK_WEST);

		closestArea.sort(new Comparator<Area>() {
			public int compare(Area entry1, Area entry2) {
				return entry1.getRandomPosition().distance(myPlayer()) entry2.getRandomPosition().distance(myPlayer());
			}
		});
		getWalking().webWalk(closestArea.get(0));
		
		if(!closestArea.get(0).contains(myPlayer())
		    getWalking().webWalk(closestArea.get(0));

just add more closestArea.add(Banks.DRAYNOR); ?

or do i need to add, entry 1,2,3,4 etc also?

 

Just do closestArea.add(...); no need to make more sorters.

  • Author

Just do closestArea.add(...); no need to make more sorters.

 

 

done like so:

List<Area> closestArea = new ArrayList<Area>();

@[member=Override]
	public void onStart() {
		gui = new GUI();
		closestArea.add(Banks.AL_KHARID);
		closestArea.add(Banks.DRAYNOR);
		closestArea.add(Banks.VARROCK_WEST);
		closestArea.sort(new Comparator<Area>() {
			public int compare(Area entry1, Area entry2) {
				return entry1.getRandomPosition().distance(myPlayer()) entry2.getRandomPosition().distance(myPlayer());
			}
		});
	}


although on line :

return entry1.getRandomPosition().distance(myPlayer()) entry2.getRandomPosition().distance(myPlayer());

 

it wants me to insert ; to complete the block (if i do insert ; then entry 2 gets full error)

done like so:

List<Area> closestArea = new ArrayList<Area>();

@[member='Override']
	public void onStart() {
		gui = new GUI();
		closestArea.add(Banks.AL_KHARID);
		closestArea.add(Banks.DRAYNOR);
		closestArea.add(Banks.VARROCK_WEST);
		closestArea.sort(new Comparator<Area>() {
			public int compare(Area entry1, Area entry2) {
				return entry1.getRandomPosition().distance(myPlayer()) entry2.getRandomPosition().distance(myPlayer());
			}
		});
	}


although on line :

return entry1.getRandomPosition().distance(myPlayer()) entry2.getRandomPosition().distance(myPlayer());

 

it wants me to insert ; to complete the block (if i do insert ; then entry 2 gets full error)

oops should be:

return entry1.getRandomPosition().distance(myPlayer()) - entry2.getRandomPosition().distance(myPlayer());

you should only add the banks in on start, then sort the array list when you want to walk or do something.

Edited by Vilius

  • Author

oops should be:

return entry1.getRandomPosition().distance(myPlayer()) - entry2.getRandomPosition().distance(myPlayer());

you should only add the banks in on start, then sort the array list when you want to walk or do something.

thank you :D no error, ill let you know how it works

oops should be:

return entry1.getRandomPosition().distance(myPlayer()) - entry2.getRandomPosition().distance(myPlayer());

you should only add the banks in on start, then sort the array list when you want to walk or do something.

 

Why would you sort the Areas to determine if you are in the closest bank? Just loop over the Area[]... if you are in one of the Areas, guess what? You are in the closest bank. 

 

To walk to the closest bank you can just call getWalking().webWalk(bankAreas)

Edited by Explv

Why would you sort the Areas to determine if you are in the closest bank? Just loop over the Area[]... if you are in one of the Areas, guess what? You are in the closest bank. 

 

To walk to the closest bank you just call getWalking().webWalk(bankAreas)

Ofcourse, you can do that too, I'm not judging. I just find sorting the areas to be more useful rather than just iterating through them.

And for the new guy it will be easier to understand boolean logic, I guess.

Albeit this snippet I posted was for closest position finding from an array list, but it works for areas too, more versatile I suppose.

Edited by Vilius


private enum Bank {

DRAYNOR(Banks.DRAYNOR),

AL_KHARID(Banks.AL_KHARID),

LUMBRIDGE(Banks.LUMBRIDGE_UPPER),

FALADOR_EAST(Banks.FALADOR_EAST),

FALADOR_WEST(Banks.FALADOR_WEST),

VARROCK_EAST(Banks.FALADOR_EAST),

VARROCK_WEST(Banks.VARROCK_WEST),

SEERS(Banks.CAMELOT),

CATHERBY(Banks.CATHERBY),

EDGEVILLE(Banks.EDGEVILLE),

YANILLE(Banks.YANILLE),

GNOME_STRONGHOLD(Banks.GNOME_STRONGHOLD),

ARDOUNGE_NORTH(Banks.ARDOUGNE_NORTH),

ARDOUNE_SOUTH(Banks.ARDOUGNE_SOUTH),

CASTLE_WARS(Banks.CASTLE_WARS),

DUEL_ARENA(Banks.DUEL_ARENA),

PEST_CONTROL(Banks.PEST_CONTROL),

CANIFIS(Banks.CANIFIS),

BLAST_FURNACE(new Area(1949, 4956, 1947, 4958)),

TZHAAR(Banks.TZHAAR);

private final Area area;

Bank(Area area) {

this.area = area;

}

}

public static Area closestTo(Entity e) {

HashMap<Bank, Integer> distMap = new HashMap<Bank, Integer>();

for (Bank b : Bank.values()) {

distMap.put(b, e.getPosition().distance(b.area.getRandomPosition()));

}

HashMap<Integer, Bank> distMapSorted = sortByDistance(distMap);

Area cBank = distMapSorted.values().toArray(new Bank[Bank.values().length])[0].area;

return cBank;

}

private static <K, V extends Comparable<? super V>> HashMap<V, K> sortByDistance(Map<K, V> map) {

HashMap<V, K> result = new LinkedHashMap<>();

Stream<Map.Entry<K, V>> st = map.entrySet().stream();

st.sorted(Map.Entry.comparingByValue()).forEachOrdered(e -> result.put(e.getValue(), e.getKey()));

return result;

}

@LP

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.