Hey guys this is my first private script and it basically buys an item from a store, hops, and repeats. However, i keep getting this weird problem where my player trades/closes the store 3-4 times before it actually starts buying the item. In addition, i keep getting this error below but the script continues to run fine. However, after literally 20 minutes every time, the script just stops working and sits there (still running though).
the error:
[ERROR][bot #1][05/10 11:10:14 PM]: Error in script executor!
java.lang.NullPointerException
at org.osbot.rs07.api.Store.getAmount(jg:173)
at main.onLoop(main.java:48)
at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(lk:242)
at java.lang.Thread.run(Thread.java:745)
Here is the method i use to trade the NPC:
NPC example = npcs.closest("Example");
if (example != null){
example.interact("Trade");
sleep(random(87,167));
}
Store exampleStore = getStore();
int amount = exampleStore.getAmount("Example item");
while (amount > 200) {
exampleStore.buy("Example item", 10);
amount = exampleStore.getAmount("Example item");
sleep(random(18,39));
}
vialStore.close();
sleep(random(48,107));
So in short, my main questions are:
- Why does it keep spam trading/closing 3-4 times?
- Why does the script just stop functioning after 20ish minutes? (Could be due to hopping, interactiong, etc. not sure)
If someone wants me to pm them my source code just ask! It might be helpful in figuring out whats going on. Thanks so much!