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.

Plague's Snippet Collection

Featured Replies

Gonna consolidate all of the useful snippets i find or am shown by other users here, so i don't have to mess up my bookmarks.

 

Timer Code:

 

 

For a timer you could do something like this:

//Class variable
private long timer;

//when you want to start/reset the timer
timer = System.currentTimeMillis();

//to check if the timer is past a certain amount of time, ex. 1 min.
System.currentTimeMillis() - timer >= 60000;

 

NPC Filtering:

 

NPCs closest returns a single NPC, not a collection of NPCs for you to filter.

 

You want something like:

 Optional<NPC> suitableNpc = getNpcs().getAll().stream().filter(npc -> npc.getHealthPercent() > 1).findFirst();
        if (suitableNpc.isPresent()) {
            suitableNpc.get().interact("examine");
        }

You may want to look a little bit into Java 8 streams before using them.

 

 

Edit:

Or better yet you can use the FilterAPI way which is native to OSBot smile.png
 

getNpcs().closest(new Filter<NPC>() {
            @[member='Override']
            public boolean match(NPC obj) {
                return obj.getHealthPercent() > 1;
            }
        }) ;

 

EntityAPI: http://osbot.org/api/org/osbot/rs07/api/EntityAPI.html

 

 

Lvl 2 Enchant Ring @ Falador East Bank: (wrote this and decided not to use it feels.png)
RS2Widget enchant = getWidgets().get(218, 17);
    		Item emeraldRing = getInventory().getItem("Emerald ring");
    		if(!faladorEastBank.contains(myPlayer())) {
    			status = "Walking to falador east bank.";
    			getWalking().webWalk(faladorEastBank);
    		}
    		if(!getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of air")) {
    			if(!inventory.contains("Staff of air")) {
    				if(!bank.isOpen()) {
    					status = "Opening bank.";
    	    			getBank().open();
    	    			Constants.condSleep(10000, 300, () -> bank.isOpen()); 
    	    		}
    				status = "Withdrawing staff of air.";
    				bank.withdraw("Staff of air", 1);
    				Constants.condSleep(10000, 300, () -> inventory.contains("Staff of air")); 
    			}
    			getEquipment().equip(EquipmentSlot.WEAPON,"Staff of air");
    			status = "Equiping Staff of air.";
    			Constants.condSleep(10000, 300, () -> getEquipment().isWearingItem(EquipmentSlot.WEAPON, "Staff of air"));
    		} 	
    		
    		if(!getInventory().contains("Emerald ring") || !getInventory().contains("Cosmic rune")) {
    			if(!bank.isOpen()) {
    				status = "Opening bank.";
        			getBank().open();
        			Constants.condSleep(10000, 300, () -> bank.isOpen()); 
        		}
    			status = "Depositing inventory.";
    			getBank().depositAllExcept("Emerald ring", "Cosmic rune");
    			Constants.condSleep(10000, 300, () -> inventory.onlyContains("Cosmic rune"));
    			status = "Withdrawing cosmics/emerald rings.";
    			bank.withdrawAll("Cosmic rune");
    			bank.withdrawAll("Emerald ring");
    			Constants.condSleep(10000, 300, () -> inventory.contains("Emerald ring", "Cosmic rune"));    			
    		}
    		if(inventory.contains("Emerald ring", "Cosmic rune")) {
    			if(bank.isOpen()) {
    				status = "Closing bank.";
    				bank.close();
    			}
    			if(!getTabs().open(Tab.MAGIC)) {
    				status = "Opening Magic tab.";
    				getTabs().open(Tab.MAGIC);
    			}
    			if(enchant != null && enchant.isVisible()) {
    				enchant.interact();
    				status = "Clicking enchant.";
    				if(getTabs().open(Tab.INVENTORY)) {
    					if(emeraldRing != null) {
    						status = "Clicking emerald ring.";
    						emeraldRing.interact();
    					}
    					Constants.condSleep(10000, 300, () -> getTabs().open(Tab.MAGIC)); 
    				}
    			}
    			
    			
    		}
Players are nearby: 
public boolean imAlone()	{
		Area area = alchSpot;//create your own area
		int amount = 0;
		
		for (Player player: players.getAll())	{
			if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())){
				if (area.contains(player))	{
					amount++;
				}
			}
		}
		return amount == 0;	
	}

 

Edited by PlagueDoctor

  • 2 months later...
  • 2 weeks later...

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.