sombotdude Posted January 1, 2019 Share Posted January 1, 2019 (edited) So I noticed that some of my bots had been sporadically stopping when left over night, but when I logged back in none of them had met the conditions I set in the script for it to stop and log out. Basically the script logs out and stops if it has less than 2GP left in its inventory, checked by using the following code & with it logging how much GP it has left in the inventory before doing so: log("Coins in inventory: " + getInventory().getAmount("Coins")); if (getInventory().getAmount("Coins") > 2) { //do stuff } else { log("No coins left in inventory! Logging out."); stop(); } So by checking the log I would see something like this: "Coins in inventory: 17698" "Coins in inventory: 17696" "Coins in inventory: 17694" "Coins in inventory: 0" "No coins left in inventory! Logging out." Yet then when I log back into the account, it has 17694 GP still in its inventory? Anybody know of why the getInventory().getAmount("Coins") would return 0, despite there still being thousands of GP in the inventory? Also note that the GP doesn't go anywhere in the script, the script purely just buys an item through dialogue with an NPC, with the GP just sat in the inventory. Edit - Here's an actual screenshot from the log as it happened again as I was watching: Note I also added getAmount(995) (hence the (ID) Coins in inventory: ) just test if it was some issue with it checking the getAmount("Coins). Thanks in advance for any help. Edited January 1, 2019 by sombotdude Better Example Quote Link to comment Share on other sites More sharing options...
NoxMerc Posted January 1, 2019 Share Posted January 1, 2019 Can you replicate the issue? Run a test script that looks like @Override public int onLoop() throws InterruptedException { log(getInventory().getAmount("Coins")); return 500; } While this is running, go through the same process manually that your bot does, and see if you notice it occasionally logging 0. Quote Link to comment Share on other sites More sharing options...
sombotdude Posted January 1, 2019 Author Share Posted January 1, 2019 (edited) 14 minutes ago, NoxMerc said: Can you replicate the issue? Run a test script that looks like @Override public int onLoop() throws InterruptedException { log(getInventory().getAmount("Coins")); return 500; } While this is running, go through the same process manually that your bot does, and see if you notice it occasionally logging 0. Yeah this it what I have just been trying, as of yet I cannot get it to log 0 and I'm not too hopefully of being able to see it do so, as sometimes the script runs for 17 hours+ with no issues. Edited January 1, 2019 by sombotdude Quote Link to comment Share on other sites More sharing options...
NoxMerc Posted January 1, 2019 Share Posted January 1, 2019 (edited) You could do something like int verificationAttempts = 5; long goldAmt = 0; for (int i = 0; i < verificationAttempts; i++) { goldAmt = getInventory().getAmount("Coins"); if (goldAmt > 0) break; } if (goldAmt == 0) { // We tried 5 times to find gold } Granted this isn't perfect, but if your assumption is true that it's somehow returning 0 at times... I'm still convinced there's a flaw in the script's logic somewhere, and this is pretty hackish. Edited January 1, 2019 by NoxMerc Quote Link to comment Share on other sites More sharing options...