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.

Free script / snippet consulting service

Featured Replies

  • Author
package Darkcore;

/**
 * Created by ISOLATE on 11/09/14.
 */
public abstract class Job {
    
    public abstract boolean Activate();
    public abstract void Run();
    
}
 

 

Body-less methods, no instance variables...

Turn that baby into an interface ;) 

Note if you want add me on the list of helpers. I think :troll: I know enough of java to help out around here.

I understand the question but it's a strange one to be asking.

I would be very interested to see how your script is formatted.

An example of how id expect to see this:

public int loop() {        final int RANDOM_ID = 666;        if (Inventory.contains(RANDOM_ID)) {            if (Bank.isOpen()) {                Bank.close();                //sleep            } else {                //do whatever it is you're doing in this example            }        } else {            if (Bank.isOpen()) {                //Use Bank                //sleep            } else {                Bank.open();                //sleep            }        }        return 900;    }
would be to run all your checks to see what you should be doing.

or use an Action/Task/Job system would also work .

eg:

Job Class (not sure what the api one here is (if any))

package Darkcore;/** * Created by ISOLATE on 11/09/14. */public abstract class Job {        public abstract boolean Activate();    public abstract void Run();    }

Example Banking Inheritance

public class Banking extends Job {    @Override    public boolean Activate() {        return Inventory.isFull();    }    @Override    public void Run() {        if (Variables.BANK_AREA.contains(getMyPlayer())) {            if (Bank.isOpen()) {                Bank.depositInventory();                Time.sleep(300, 700);            } else {                Bank.open();                Time.sleep(200, 800);            }        } else {            //Walk to bank        }    }}

Just for future reference, only uppercase variables that are constant and known at compile time. Since RANDOM_INT is inside a method declaration, despite it being final, the value is not known until the method is called at runtime where the variable will be recreated every time the method is called.

Just for future reference, only uppercase variables that are constant and known at compile time. Since RANDOM_INT is inside a method declaration, despite it being final, the value is not known until the method is called at runtime where the variable will be recreated every time the method is called.

Thank-you for the advice but i'll admit this is something i already know.

  • 1 month later...

Thank-you for the advice but i'll admit this is something i already know.

why didnt you do it then.

  • 2 weeks later...

free bump for a real ********a.

 

thanks for helping noobs

Hi my name is Andrew and I am very new to writing my own scripts. I tried to code my own goblin killer but it is very slow and is just not as effective as id like it to be. I don't have any specific questions right now but here is my code, any suggestions? And also how do i post my code neatly like above?

 

 

 

 

@Override
public int onLoop() throws InterruptedException {
Player myself = myPlayer();
NPC victim = npcs.closest("Goblin");
if(!myself.isUnderAttack()){
if(victim != null){
if(victim.isAttackable()){
victim.interact("Attack");
sleep(random(2000, 3000));
}
}
}
// TODO Auto-generated method stub
return 50;
}

 

Hi my name is Andrew and I am very new to writing my own scripts. I tried to code my own goblin killer but it is very slow and is just not as effective as id like it to be. I don't have any specific questions right now but here is my code, any suggestions? And also how do i post my code neatly like above?

 

 

 

 

@Override
public int onLoop() throws InterruptedException {
Player myself = myPlayer();
NPC victim = npcs.closest("Goblin");
if(!myself.isUnderAttack()){
if(victim != null){
if(victim.isAttackable()){
victim.interact("Attack");
sleep(random(2000, 3000));
}
}
}
// TODO Auto-generated method stub
return 50;
}

 

 

To make it more efficient, at the moment it is loading the nearest goblin, clicking attack and then sleeping for a while. What you could do is use a filter to go through all the nearby enemies and pick out the right one. For example, using the following method:

	public NPC getClosestNPCInAreaForName(Area area, String name) {
		NPC closest = null;
		double lowest = Double.MAX_VALUE;
		for (NPC npc : this.getNpcs().getAll()) {
			if (npc != null && npc.exists() && area.contains(npc)) {
				final String npcName = npc.getName();
				final double d = npc.getPosition().distance(this.myPosition());
				if (npcName.equalsIgnoreCase(name) && area.contains(npc)
						&& d < lowest) {
					closest = npc;
					lowest = d;
				}
			}
		}
		return closest;
	}

Also, to post code neatly, use this button: 

 

3MVfI8r.png

 

Good luck!

apaec

can you explain that for loop? is it looping through an array?


Because i tried implementing that code but now the bots does nothing

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.