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.

Can someone check if this script works on your PC?

Featured Replies

So I was making a script but before I decided to do that I wanted to run it. It ran 2 times but then after I added a bit more code into it, it doesn't run. 

import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.Skills;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;




import java.awt.*;
import java.util.concurrent.TimeUnit;


import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


@ScriptManifest(author = "KappaKeepo", info = "AutoFigherScript", name = "KappasAwesomeFighter", version = 0, logo = "")
public class main extends Script {


//GUI Handlers
private JFrame gui;    
    private String selectedArea;// Global String variable to store selected option
    private boolean started = false;
    


private long timeBegan;
private long timeRan;
double hpPercentage = getSkills().getDynamic(Skill.HITPOINTS) * 100 / getSkills().getStatic(Skill.HITPOINTS);


//Banking banking = new Banking();






@[member='Override']
    public void onStart() {
     timeBegan = System.currentTimeMillis();
     log("KappasAwesomeFighter");
     createGUI();




    }


    public State getState() {
if (inventory.isEmptyExcept(314, 526, 2138)) {
return State.BANKING;
}


if (hpPercentage < 50) {
//log("My HP is below 50%"); // was experimenting with this lol
//this.getInventory().interact(20,"Eat");
return State.BANKING;
}


return State.WAITING;
}




    
    private enum State{ATTACKING,WAITING,WALKING,BANKING,ANTIBAN,EAT};


    @[member='Override']
    public int onLoop() throws InterruptedException {
     if(started){


     if(selectedArea == "Edgeville Rats"){
     log("Edgeville works");
}else if(selectedArea == "Chickens"){


}else if(selectedArea == "Lumbridge Goblins"){


}else if(selectedArea == "Edgeville Men"){


}


}
        return random(200, 300);
    }




    @[member='Override']
    public void onExit() {
        log("KappasAwesomeFighter has successfully exited!");
        if(gui != null) { // If the JFrame has been created


            gui.setVisible(false); // Hide it
            gui.dispose(); // Dispose
        }
    }
    
    private String ft(long duration) 
{
String res = "";
long days = TimeUnit.MILLISECONDS.toDays(duration);
long hours = TimeUnit.MILLISECONDS.toHours(duration)
- TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
- TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
.toHours(duration));
long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
- TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
.toMinutes(duration));
if (days == 0) {
res = (hours + ":" + minutes + ":" + seconds);
} else {
res = (days + ":" + hours + ":" + minutes + ":" + seconds);
}
return res;
} 
    




    @[member='Override']
    public void onPaint(Graphics2D g) {
     if(started){
     Graphics2D gr = g;
timeRan = System.currentTimeMillis() - this.timeBegan;
g.drawString(ft(timeRan), 1, 1);
     if(myPlayer().isAnimating()){


}


     }    


    }


    private void antiBan() throws InterruptedException{
     if(started){


     if(!myPlayer().isAnimating() && myPlayer().isMoving()){
getTabs().open((Tab.SKILLS));
getSkills().hoverSkill(Skill.STRENGTH);
sleep(100 + random(400,15000));
}




}


}
    




    private void createGUI() {
       gui = new JFrame("GUI");
     final int GUI_WIDTH = 350, GUI_HEIGHT = 75;
     //get size of screen
     Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
     //calc x and y 
     final int gX = (int) (screenSize.getWidth() / 2) - (GUI_WIDTH / 2);
     final int gY = (int) (screenSize.getHeight() / 2) - (GUI_HEIGHT / 2);
     
      gui.setBounds(gX, gY, GUI_WIDTH, GUI_HEIGHT);


         gui.setResizable(false); // Disable resizing
         JPanel panel = new JPanel();
         gui.add(panel);
         JLabel label = new JLabel("Select an area to train at:"); // Create a label
         label.setForeground(Color.white); // Set text colour to white
         panel.add(label); // Add it to the JPanel 
        


      // Create a select box for tree options
      JComboBox<String> areaSelector = new JComboBox<>(new String[]{"Edgeville Rats", "Lumbridge Goblins", "Edgeville Men"});
              
      // Add an action listener, to listen for user's selections, assign to a variable called selectedTree on selection.
      areaSelector.addActionListener(e -> selectedArea = areaSelector.getSelectedItem().toString());
              
      // Add the select box to the JPanel
      panel.add(areaSelector); 
      JButton startButton = new JButton("Start");
                 
      startButton.addActionListener(e -> { // This code is called when the user clicks the button
         started  = true; // Set the boolean variable started to true
         gui.setVisible(false); // Hide the GUI
     });
     panel.add(startButton); // Add the button to the 
     
     gui.setVisible(true);
    }
}

I commented out most of them because I thought they were the problem. However, it doesn't seem like that's the case. So I'm not sure if it's the botclient itself or my script. Because it doesn't seem like other scripts I try to run doesn't work either. 

Edited by lol0

So I was making a script but before I decided to do that I wanted to run it. It ran 2 times but then after I added a bit more code into it, it doesn't run. 

double hpPercentage = getSkills().getDynamic(Skill.HITPOINTS) * 100 / getSkills().getStatic(Skill.HITPOINTS);

 

 

Try moving that line into getState() (or remove it)

Edited by Explv

  • Author

Try moving that line into getState() (or remove it)

 

I love you! That was it. 

Why exactly did that happen? I'm learning Java as I go as I'm used to C# but I've never encountered something like this before. 

I love you! That was it. 

Why exactly did that happen? I'm learning Java as I go as I'm used to C# but I've never encountered something like this before. 

 

To put it very simply, you can't make API calls before onStart() is called, because context has not yet been exchanged with your script

  • Author

To put it very simply, you can't make API calls before onStart() is called, because context has not yet been exchanged with your script

 

 

I understand that now, thanks!  

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.