Sean Posted April 10, 2016 Posted April 10, 2016 So I got this simple "Man" pick pocketer. It should just steal from the men in lumby and thats it. (Just starting out) However once its started it doesn't do anything. If anyone can spot any errors in the code then please help me out Code: import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "SuperPickpocket", author = "Sean", info = "My first script",version = 0, logo = "") public class SuperPickpocket extends Script { private NPC man; @Override public void onStart() { log("Welcome to my Trial Script (Thieving)"); man = npcs.closest("Man"); } private enum State { PICKPOCKET, WAIT; }; private State getState() { if (man != null) return State.PICKPOCKET; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case PICKPOCKET: man.interact("Pickpocket"); break; case WAIT: sleep(random(400, 600)); break; } return random(200, 300); } @Override public void onExit() { log("Thx for using this script"); } @Override public void onPaint(Graphics2D g) { } }
Token Posted April 10, 2016 Posted April 10, 2016 Your man variable is most likely null resulting in always waiting. You should search for a man in onLoop() not onStart().
Sean Posted April 10, 2016 Author Posted April 10, 2016 Your man variable is most likely null resulting in always waiting. You should search for a man in onLoop() not onStart(). Fixed it was getting this error java.lang.NoClassDefFoundError: SuperPickpocket$1 Didn't copy all the files over. But before that I changed all the "man" variables to "Man" as its case sensitive right?
Token Posted April 10, 2016 Posted April 10, 2016 Fixed it was getting this error java.lang.NoClassDefFoundError: SuperPickpocket$1 Didn't copy all the files over. But before that I changed all the "man" variables to "Man" as its case sensitive right? Java is case sensitive so it's the same if you name your variables "man" or "Man". It only matters that you use the same everywhere in your code.
Apaec Posted April 10, 2016 Posted April 10, 2016 Its awesome that youre taking this so seriously! Firstly, ensure that you run the script with the OSBot console open (aka logger). Secondly, the reason this is happening is because it's throwing NPEs (null pointer errors). To fix this, just re-define the man variable in the onLoop and getState functions (basically, always search for a new object before interacting). ~apa
Sean Posted April 10, 2016 Author Posted April 10, 2016 Its awesome that youre taking this so seriously! Firstly, ensure that you run the script with the OSBot console open (aka logger). Secondly, the reason this is happening is because it's throwing NPEs (null pointer errors). To fix this, just re-define the man variable in the onLoop and getState functions (basically, always search for a new object before interacting). ~apa Thx man. I used your tutorial to get the basics setup and the layout :P 1