Juggles Posted April 24, 2016 Posted April 24, 2016 (edited) My script tells it to log out when it is below 1000 coins. My inventory has well over 1000 coins but the Debugger is saying I have no coins in my inventory. Here is my code: if (getInventory().getAmount("Coins") <= 1000) {log("Apparently I've got less than 1000 coins?");log(("Amount of coins: ") + getInventory().getAmount("Coins"));stop();} Edited April 24, 2016 by lg_juggles 1
DragonAlpha Posted April 24, 2016 Posted April 24, 2016 (edited) Might be because OSBot *sometimes* thinks "Coins" does not exist? This may then explain why getAmount() returns 0, and gives a NPE. I get this error sometimes, sometimes my scripts would stop "Out of coins", it happened rarely though. Edited April 24, 2016 by DragonAlpha 1
Juggles Posted April 24, 2016 Author Posted April 24, 2016 (edited) Why are you getting an NPE in Store? The NPE isn't the problem though. The client is not recognizing that I have coins in the inventory. I was able to bypass this by using if (getInventory().getAmount("Coins") <= 1000 && getInventory().getAmount("Coins") > 1) { log("Apparently I've got less than 1000 coins?"); log(("Amount of coins: ") + getInventory().getAmount("Coins")); stop(); } so that means the client is not recognizing it sometimes Edited April 24, 2016 by lg_juggles
TFW Posted April 24, 2016 Posted April 24, 2016 If you are constantly hopping and the condition is being check while you are logged out, wouldn't that be the problem? I assume you are hopping since you are shop buying.
DragonAlpha Posted April 24, 2016 Posted April 24, 2016 (edited) The NPE is the problem though. The client is recognizing that I have coins in the inventory. I was able to bypass this by using if (getInventory().getAmount("Coins") <= 1000 && getInventory().getAmount("Coins") > 1) { log("Apparently I've got less than 1000 coins?"); log(("Amount of coins: ") + getInventory().getAmount("Coins")); stop(); } so that means the client is recognizing it sometimes Interesting. So the client sometimes tells us there are 0 coins in the inventory, I am unsure why at this point. So you are avoiding this by adding an extra check: Coins under 1000 Coins greater than 1 Because this solution works, that does possibly hint towards something in the client. I would dismiss this as scripter error, but, it happens with me too Edited April 24, 2016 by DragonAlpha
Juggles Posted April 24, 2016 Author Posted April 24, 2016 If you are constantly hopping and the condition is being check while you are logged out, wouldn't that be the problem? I assume you are hopping since you are shop buying. I thought it wouldn't check the condition if it was logged out? That may be the problem then.
DragonAlpha Posted April 24, 2016 Posted April 24, 2016 I thought it wouldn't check the condition if it was logged out? That may be the problem then. Try adding this at the top of your onLoop(). Let us know if the problem still happens. if(client.getLoginState() == Client.LoginState.LOGGED_OUT) { log("Waiting for login"); return; // return 250; }
TFW Posted April 24, 2016 Posted April 24, 2016 I thought it wouldn't check the condition if it was logged out? That may be the problem then. Not sure. Just a thought.
Final Posted April 24, 2016 Posted April 24, 2016 (edited) TFW is correct, the client handles data in a very obscure way keeping some data loaded when logged out. You should always check your login state to be 30 before peforming an action otherwise this will create increasingly annoying issues. Ultimately youll want to make sure there is an item called coins in your inventory (the item is not null ) and use this instance to invoke the method, as well as if you are in game before attempting any in game interactions. Edited April 24, 2016 by Final 1
The Hero of Time Posted May 9, 2016 Posted May 9, 2016 Might be because OSBot *sometimes* thinks "Coins" does not exist? This may then explain why getAmount() returns 0, and gives a NPE. I get this error sometimes, sometimes my scripts would stop "Out of coins", it happened rarely though. thats since the inventory hasn't loaded yet. be sure to open the inventory if its not already before checking. errors like these will happen right when you log in