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.

Need some help please.

Featured Replies

How come you made your own methods and threw exceptions in them? There's no need to. And also when using the water jug on the fountain it's not "->" it's "use".

Post this to the scripting help forum. I'm on mobile right now so I can't check this all thoroughly.

I'am currently creating a script to fill empty jugs with water,

i already got this but when i try to load it in OSbot it crashes code :

 

http://pastebin.com/9kiDJLvK

 

thanks in advance,

Jelleplomp

                if(this.equipment.contains(1935))

should be inventory

 

return 0;

not a good idea

I don't really know why you put try/catch around everything

when you run it and it breaks in the client it should generate a stack trace/error report

for you to read, it tells you where the errors are and what they are.

if you could post that here it'd be alot easier to help.

  • Author
                if(this.equipment.contains(1935))

should be inventory

 

return 0;

not a good idea

I don't really know why you put try/catch around everything

when you run it and it breaks in the client it should generate a stack trace/error report

for you to read, it tells you where the errors are and what they are.

if you could post that here it'd be alot easier to help.

 

 

I've changed the try/catch to throws InterruptedException,

also changed the equipment to inventory but still when it's looking for which state it should use in the method: getState()

it always returns the one outside the actual ones i need. thats why it gives me the null error.

 

 

new code: 

 

 

package jugfiller;
 
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
 
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.api.ui.Message.MessageType;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.Area;
 
@ScriptManifest(author = "JellePlomp", info = "Fills jugs with water", logo = "", name = "jugFiller", version = 1)
public class JugFiller extends Script 
{
 
Position[] PATH_TO_BANK = { new Position(3281,3180,0),
   new Position(3270,3167,0) };
 
Position[] PATH_TO_FOUNTAIN = { new Position(3281,3180,0),
    new Position(3292,3175,0) };
int fountainTimes = 0;
public Area AlKharidBank = new Area(3269, 3170, 3272, 3162);
public Area AlKharidFountain = new Area(3290,3170,3295,3175);
public String state = "";
long startTime;
 
public enum State 
{
BANK_JUGS, //als hij geen jugs meer heeft maar WEL water, en in bank is
FILL_JUGS, //als hij empty jugs heeft en in de area fountain is
CRASH;
}
 
public void onStop() {}
public void onStart() 
{
state = "Starting up...wait a moment";
startTime = System.currentTimeMillis();
}
 
public State getState()
{
if(this.inventory.contains(new String[] {"Jugs"})) 
{
return State.FILL_JUGS;
}
 
if(!this.inventory.contains(new String[] {"Jugs"}) && this.inventory.contains(new String[] {"jug of water"})) 
{
return State.BANK_JUGS;
}
return State.CRASH;
}
 
public int onLoop() throws InterruptedException {
switch(getState()) 
{
case BANK_JUGS:
bank();
break;
case FILL_JUGS:
fill();
break;
case CRASH:
log("crashs here");
break;
default:
break;
 
}
   return random(200, 300);
}
 
public void bank() throws InterruptedException {
if (AlKharidBank.contains(myPlayer())) {
this.state = "BANKING_JUGS";
if (!this.bank.isOpen()) {
this.bank.open();
withdrawJugs();
} else
withdrawJugs();
} else if (AlKharidFountain.contains(myPlayer())) {
this.state = "WALKING_TO_BANK";
this.safeWalkTo(this.PATH_TO_BANK);
EXECUTE_ANTIBAN();
}
}
 
public void fill() throws InterruptedException {
if (AlKharidFountain.contains(myPlayer())) {
this.state = "FILLING_JUGS";
RS2Object fountain = (RS2Object)this.objects.closest(new String[] { "Fountain" });
if (fountain != null) {
getInventory().getItem(new String[] { "Jug" }).interact(new String[] { "Use" });
fountain.interact(" -> ");
MethodProvider.sleep(random(18000, 20000));
}
} else if (AlKharidBank.contains(myPlayer())) {
this.state = "WALKING_TO_FOUNTAIN";
this.safeWalkTo(this.PATH_TO_FOUNTAIN);
EXECUTE_ANTIBAN();
}
}
 
private void safeWalkTo(Position[] p) throws InterruptedException {
        this.getLocalWalker().walkPath(p);
        Position lastPos = p[p.length - 1];
        while (true) {
            double lastDistance = distanceSquared(this.myPosition(), lastPos);
            if (lastDistance < 4.5d) {
                break;
            }
            sleep(3000);
            if (Math.abs(distanceSquared(this.myPosition(), lastPos) - lastDistance) < 1.1d) {
                ArrayList<Position> shortenedPath = new ArrayList<Position>();
                boolean startAdding = false;
                for (Position pos : p) {
                    if (distanceSquared(this.myPosition(), pos) < 100d) {
                        startAdding = true;
                    }
                    if (startAdding) {
                        shortenedPath.add(pos);
                    }
                }
                this.getLocalWalker().walkPath(shortenedPath);
            }
        }
    }
 
    private double distanceSquared(Position p1, Position p2) {
        return Math.pow(p1.getX() - p2.getX(), 2d) + Math.pow(p1.getY() - p2.getY(), 2d);
    }
 
public void withdrawJugs() throws InterruptedException {
this.bank.depositAll();
this.bank.withdrawAll("Jug");
this.bank.close();
}
 
public void EXECUTE_ANTIBAN() throws InterruptedException {
Random r1 = new Random();
float chance = r1.nextFloat();
if (chance <= 0.4F) {
antiban();
}
}
 
public void antiban() throws InterruptedException {
int select = random(3, 6);
switch (select) {
case 3:
int pitch = random(22, 67);
getCamera().movePitch(pitch);
break;
 
case 4:
int yaw = random(1, 360);
getCamera().moveYaw(yaw);
break;
 
case 5:
List<Player> p = getPlayers().getAll();
if (p != null) {
int randomNum = Script.random(0, p.size() - 1);
Player randomPlayer = (Player) p.get(randomNum);
if (randomPlayer != null) {
randomPlayer.hover();
getMouse().click(true);
sleep(random(200, 500));
}
}
 
break;
 
case 6:
List<Player> pl = getPlayers().getAll();
if (pl != null) {
int randomNum = Script.random(0, pl.size() - 1);
Player randomPlayer = (Player) pl.get(randomNum);
if (randomPlayer != null) {
randomPlayer.hover();
}
}
 
break;
}
}
 
public void onPaint(Graphics2D g) {
long elapsed = System.currentTimeMillis() - startTime;
g.setColor(Color.YELLOW);
g.setFont(new Font("Arial", Font.PLAIN, 10));
g.drawString("Visited fountain: "+fountainTimes+" times", 320, 290);
g.drawString("run time: "+format(elapsed)+" times", 320, 315);
g.drawString("current state: "+state+"", 320, 330);
}
 
public void onMessage(Message c) {
if (c.getType() == MessageType.GAME) {
String m = c.getMessage().toLowerCase();
try {
if(m.contains("fill")) {
fountainTimes++;
}
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
 
public String format(long time) {
StringBuilder string = new StringBuilder();
long totalSeconds = time / 1000L;
long totalMinutes = totalSeconds / 60L;
long totalHours = totalMinutes / 60L;
int seconds = (int) totalSeconds % 60;
int minutes = (int) totalMinutes % 60;
int hours = (int) totalHours % 24;
if (hours > 0) {
string.append(hours + "h ");
}
if (minutes > 0) {
string.append(minutes + "m ");
}
string.append(seconds + "s");
return string.toString();
}
}
 

 

btw thank you for helping (:

 

 

Can you please post the error it throws.

those errors tell you what the problem is/where

  • Author

Can you please post the error it throws.

those errors tell you what the problem is/where

ahh managed to fix it ! I misspelled jug....

but now... the local walker is broke or something it just wont walk...

  • Author

Can you please post the error it throws.

those errors tell you what the problem is/where

nevermind i got it fixed tyvm for the help !!

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.