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.

Fishing script help

Featured Replies

Hello, so I'm busy making a trout/salmon fishing script I know it's far from finished but somehow the bot always seems to get a nullpointer exception and I can't seem to find the problem... Can somebody please help me out?
 

Thanks in advance GaetanoH

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

import java.awt.*;

/**
 * Created by Gaetano on 15/03/16.
 */
@ScriptManifest(name = "Salmon/Trout Fisher", author = "GaetanoH", version = 1.0, info = "", logo = "")
public class Fisher extends Script {

    public enum State {
        FISHING, DROPPING;
    }

    public State getState(){
        if(!inventory.contains("Raw trout") && !inventory.contains("Raw salmon")){
            log("fishing");
            return State.FISHING;
        }

        if(inventory.isFull() && inventory.contains("Raw trout") && inventory.contains("Raw salmon")){
            log("dropping");
            return State.DROPPING;
        }

        return null;
    }

    @Override
    public void onStart() throws InterruptedException {
        log("Welcome to my Barbarian Village Fisher/Cooker, start with a fly fishing rod with enough feathers, a tinderbox and a axe equipped.");
    }

    @Override
    public void onExit() throws InterruptedException {
        log("Thanks for using my script");
    }

    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()) {
            case FISHING:
                if(!myPlayer().isAnimating()){
                    getNpcs().closest("Fishing spot").interact("Lure");
                }
                break;
            case DROPPING:
                getInventory().dropAllExcept("Fly fishing rod", "Feather");
                break;
        }

        return random(500, 800);
    }

    @Override
    public void onPaint(Graphics2D g) {

    }
}

getNpcs().closest("Fishing spot").interact("Lure");

 

Possibly there. could be that the fishing spot is null

  • Author

Oh yeah..., knew it was something small, thank you man!


It was the fact that I checked if you had salmon/trout before fishing which ended up not working and just standing still

Oh, and you should always look at the logger and see what line the error occurs one ;)

Yeah i saw what line it was but didn't see my mistake smile.png

tip: NullPointerException usually happens when you didnt check if something was null or not.

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.