March 15, 20169 yr 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) { } }
March 15, 20169 yr getNpcs().closest("Fishing spot").interact("Lure"); Possibly there. could be that the fishing spot is null
March 15, 20169 yr 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
March 15, 20169 yr Oh, and you should always look at the logger and see what line the error occurs one ;)
March 15, 20169 yr Oh, and you should always look at the logger and see what line the error occurs one
March 15, 20169 yr Yeah i saw what line it was but didn't see my mistake tip: NullPointerException usually happens when you didnt check if something was null or not.
Create an account or sign in to comment