Sean Posted April 10, 2016 Share 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) { } } Link to comment Share on other sites More sharing options...
Token Posted April 10, 2016 Share 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(). Link to comment Share on other sites More sharing options...
Sean Posted April 10, 2016 Author Share 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? Link to comment Share on other sites More sharing options...
Token Posted April 10, 2016 Share 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. Link to comment Share on other sites More sharing options...
Apaec Posted April 10, 2016 Share 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 Link to comment Share on other sites More sharing options...
Sean Posted April 10, 2016 Author Share 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 Link to comment Share on other sites More sharing options...