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.

My first OSBot Script

Featured Replies

Simultaneous intro and script submission --

CS student, adept understanding of programming logic, but with little Java knowledge/experience

 

I made this Master Farmer thieving script and want to see what criticism it receives..

NPC masterFarmer = getNpcs().closest("Master Farmer");
 int lastCount = getInventory().getEmptySlotCount();
 int randReturn = random(40, 138);
 int randSleep = random(450, 850);
 int corblimeySleep = random(1800, 2000);
 RS2Object bankBooth = getObjects().closest("Bank booth");
 InteractionEvent useBank = new InteractionEvent(bankBooth, "Bank");


// log(randReturn);

 if(myPlayer().getHealthPercent() < 40){
     getInventory().interact("Eat", "Swordfish");
     log("Hungry, eating now");

     if(!getInventory().contains("Swordfish")) {
         if (bankBooth.exists()) {
             execute(useBank);
             sleep(randSleep);
             log("Sleeping for: " + randSleep);
             useBank.setOperateCamera(false);
             useBank.setWalkTo(true);
             log("The Bank is open");
             if (getBank().depositAll()) { // we will deposit all ..
                 log("We deposit all");
                 if (getBank().withdraw("Swordfish", 7)) {
                     new ConditionalSleep(2000, 1000) { //sleep until the inv is empty
                         @Override
                         public boolean condition() throws InterruptedException {
                             return !getInventory().isFull();
                         }
                     }.sleep();
                 }
             }
         }


     }
 }


 if (!getInventory().isFull() && getInventory().contains("Swordfish")) {
     InteractionEvent pickEvent = new InteractionEvent(masterFarmer, "Pickpocket");
     pickEvent.setOperateCamera(false);
     pickEvent.setWalkTo(true);

     if (masterFarmer.exists()) {
         log("Master Farmer found");
         execute(pickEvent);
         log("Picking pocket");
         if(myPlayer().isHitBarVisible()){
             sleep(2000);
             log("Cor Blimey!!");
         }
         new ConditionalSleep(100,25) {
             @Override
             public boolean condition() throws InterruptedException {
                 return getInventory().getEmptySlotCount() < lastCount;
             }
         }.sleep();


     }
     else{
         log("Can not find");
     }
 }
 else {
     log("Inventory is full");
     if(bankBooth.exists()){
         execute(useBank);
         sleep(randSleep);
         log("Sleeping for: " + randSleep);
         useBank.setOperateCamera(false);
         useBank.setWalkTo(true);
             log("The Bank is open");
             if (getBank().depositAll()) { // we will deposit all ..
                 log("We deposit all");
                 if (getBank().withdraw("Swordfish", 5)) {
                     new ConditionalSleep(2000, 1000) {
                         @Override
                         public boolean condition() throws InterruptedException {
                             return !getInventory().isFull();
                         }
                     }.sleep();
                 }
             }
         }
         else {
             log("The bank is closed");
             if (getBank().open()) {  //open the bank
                 log("We opened the bank");
                 new ConditionalSleep(3000, 1500) {
                     @Override
                     public boolean condition() throws InterruptedException {
                         return getBank().isOpen();
                     }
                 }.sleep();
             }
         }
     }



 return randReturn;}

 

Edited by ohdonpiano
im a nub

I would extract it to methods to improve readability.  And try to make it as generic as possible to reduce duplicate code.

Edited by KEVzilla

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.