csvernon Posted October 22, 2017 Share Posted October 22, 2017 (edited) Hello everyone, this is my first script. It will probably look terrible to an experienced eye. Currently it checks if it needs to bank, starts the previous dream, enters NMZ, kills Elvarg, loots his bones, leaves, and does it all again. I'm running into the issue that NMZ is very laggy, script wont respond to user input, has high CPU and Memory usage. Any advise is welcome! case FIGHT: { target = npcs.closest("Elvarg"); target.interact("Attack"); sleep(random(2500, 4800)); new ConditionalSleep(4000, 500) { @Override public boolean condition() throws InterruptedException { return myPlayer().isUnderAttack(); } }.sleep(); Edited October 23, 2017 by csvernon Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 22, 2017 Share Posted October 22, 2017 Check the logger, you are probably getting a nullPointer or something. Check it and post it here Quote Link to comment Share on other sites More sharing options...
csvernon Posted October 22, 2017 Author Share Posted October 22, 2017 (edited) Error in Script executor! java.lang.NullPointerException at main.onLoop(Main.jva:85) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134) at java.lang.Thread.run(Unknown Source) seems to happen right after I turn on prayers to fight elvarg, so my script target = npcs.closest("Elvarg"); target.interact("Attack"); seems busted 28 minutes ago, HunterRS said: Check the logger, you are probably getting a nullPointer or something. Check it and post it here Edited October 22, 2017 by csvernon Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 22, 2017 Share Posted October 22, 2017 12 minutes ago, csvernon said: Error in Script executor! java.lang.NullPointerException at main.onLoop(Main.jva:85) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134) at java.lang.Thread.run(Unknown Source) seems to happen right after I turn on prayers to fight elvarg, so my script target = npcs.closest("Elvarg"); target.interact("Attack"); seems busted Your problem is that you are not checking if you found the dragon, change target.interact to: if(target != null){ target.interact("Attack"); also, look into conditional sleeps. Quote Link to comment Share on other sites More sharing options...
Apaec Posted October 22, 2017 Share Posted October 22, 2017 16 minutes ago, csvernon said: Error in Script executor! java.lang.NullPointerException at main.onLoop(Main.jva:85) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ro:134) at java.lang.Thread.run(Unknown Source) seems to happen right after I turn on prayers to fight elvarg, so my script target = npcs.closest("Elvarg"); target.interact("Attack"); seems busted If npcs.closest returns null, and you try to call interact on it, it will throw this error. Null check it! i.e target = npcs.closest("Elvarg"); if (target!=null && target.interact("Attack")) { // do stuff } Also, when you post code, please use the provided code formatting tool in the reply box; so that it's (more) readable. There are a host of other improvements that can be made on your code; but soon enough you will find these out when your script misbehaves! GL! Apa 1 Quote Link to comment Share on other sites More sharing options...
csvernon Posted October 22, 2017 Author Share Posted October 22, 2017 (edited) K, script no longer gets errors, but now it repeatedly attacks elvarg even while in combat, condition sleep isnt working. Also getWalking().walk(new Position(6656, 6912, 1)); hasn't worked at all in NMZ and when I click on the potion to enter NMZ getObjects().closest("Plinth").interact("Drink"); mouse.click(false); I have to force the mouse to click, if will just go to the object but wont interact. The object is technically a potion that gains the "Drink" option after the dream is setup but I could only get the mouse to move there when using "Plinth" as the object. Edited October 22, 2017 by csvernon Quote Link to comment Share on other sites More sharing options...