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.

Banking issue

Featured Replies

Having script interact with bank in draynor but 50% of the time it'll go try to interact with those bank booths across from the booths in draynor bank a few tiles away..... if someone knows what I'm talking about can they please help me with it? :/


	public RS2Object closestBank() {
		RS2Object closestObject = null;
		double lastDist = 100;
		List<RS2Object> objects = client.getCurrentRegion().getObjects();
		for (RS2Object object : objects) {
			if (object != null 
					&& object.getName() != null 
					&& object.getName().equals("Bank booth")
					&& object.getDefinition().getActions()[1] != null
					&& object.getDefinition().getActions()[1].equals("Bank") ) {
				double dist = distance(object.getPosition());
				if (dist < lastDist) {
					lastDist = dist;
					closestObject = object;
				}
			}
		}
		return closestObject;
	}

Someone remove his rank for god's sake lmao 


	public RS2Object closestBank() {
		RS2Object closestObject = null;
		double lastDist = 100;
		List<RS2Object> objects = client.getCurrentRegion().getObjects();
		for (RS2Object object : objects) {
			if (object != null 
					&& object.getName() != null 
					&& object.getName().equals("Bank booth")
					&& object.getDefinition().getActions()[1] != null
					&& object.getDefinition().getActions()[1].equals("Bank") ) {
				double dist = distance(object.getPosition());
				if (dist < lastDist) {
					lastDist = dist;
					closestObject = object;
				}
			}
		}
		return closestObject;
	}

Someone remove his rank for god's sake lmao 

 

OSBot already has a method for returning a closest object list based on name tongue.png

public RS2Object getClosestBank() {
    RS2Object bank = null;
    for (RS2Object current : closestObjectListForName("Bank booth")) {
    	if (current.getDefinition().getActions() != null && Arrays.asList(current.getDefinition().getActions()).contains("Bank"))
    		bank = current;
    }
    return bank;
}

Edited by Swizzbeat

SDN scripter? when did that happen xD

	public RS2Object closestBank() {
		RS2Object closestObject = null;
		double lastDist = 100;
		List<RS2Object> objects = client.getCurrentRegion().getObjects();
		for (RS2Object object : objects) {
			if (object != null 
					&& object.getName() != null 
					&& object.getName().equals("Bank booth")
					&& object.getDefinition().getActions()[1] != null
					&& object.getDefinition().getActions()[1].equals("Bank") ) {
				double dist = distance(object.getPosition());
				if (dist < lastDist) {
					lastDist = dist;
					closestObject = object;
				}
			}
		}
		return closestObject;
	}
Someone remove his rank for god's sake lmao

Please do and give it to me :D

Oh god, does osbot not have filters? Filters makes everything look better!
 

private Filter<GameObject> bankFilter = new Filter<GameObject>() { // no need to remake the filter every time you call the bank because you can just reference this.
        @Override // its private because it's only going to be used for internal use in the getBankBooth() method
        public boolean accept(GameObject gameObject) {
            return gameObject.getName().equals("Bank booth")
                    && Arrays.asList(gameObject.getActions()).contains("Bank");
        }
    };

    public GameObject getBankBooth() {
        return GameObjects.getNearest(bankFilter);
    }

 

OSBot already has a method for returning a closest object list based on name tongue.png

public RS2Object getClosestBank() {
    RS2Object bank = null;
    for (RS2Object current : closestObjectListForName("Bank booth")) {
    	if (current.getDefinition().getActions() != null && Arrays.asList(current.getDefinition().getActions()).contains("Bank"))
    		bank = current;
    }
    return bank;
}

closestObjectListForName() - took for me 200-300ms to find the object, when client.getCurrentRegion().getObjects() took 10ms. I tested it some time ago, not sure how it's now.

 

OSBot already has a method for returning a closest object list based on name tongue.png

public RS2Object getClosestBank() {
    RS2Object bank = null;
    for (RS2Object current : closestObjectListForName("Bank booth")) {
    	if (current.getDefinition().getActions() != null && Arrays.asList(current.getDefinition().getActions()).contains("Bank"))
    		bank = current;
    }
    return bank;
}

 

Your method is obviously slower

Your method is obviously slower

 

Xavier pls

 

private interface Filter<T> { // WHY IS THIS NOT IN THE API
        boolean accept(T t);
    }

    private final Comparator<RS2Object> comparator = new Comparator<RS2Object>() {
        @Override
        public int compare(RS2Object o1, RS2Object o2) {
            return distance(o1) - distance(o2);
        }
    };

    private final Filter<RS2Object> filter = new Filter<RS2Object>() {
        @Override
        public boolean accept(RS2Object rs2Object) {
            return rs2Object.getName().equals("Bank booth")
                    && Arrays.asList(rs2Object.getDefinition().getActions()).contains("Bank");
        }
    };
    
    public RS2Object getClosestBank() {
        final List<RS2Object> allObjects = client.getCurrentRegion().getObjects();
        Collections.sort(allObjects, comparator);
        for(RS2Object obj : allObjects) {
            if(filter.accept(obj)) {
                return obj;
            }
        }
        return null;
    }
Guest
This topic is now closed to further replies.

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.