Jump to content

sombotdude

Members
  • Posts

    7
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

sombotdude's Achievements

Newbie

Newbie (1/10)

1

Reputation

  1. 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.
  2. 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.
  3. Thanks for the reply, ahh right I see now what I was doing wrong and this looks exactly like what I should be doing. But even using that code it still continues the animation if someone else has mined the rock before my player. I added some extra code to try and get a better understand of what was going on: if (rockToMine == null || !myPlayer().isAnimating() || !Rock.CLAY.hasOre(rockToMine)) { rockToMine = getObjects().closest(object -> Rock.CLAY.hasOre(object)); if (rockToMine != null && rockToMine.interact("Mine")) { new ConditionalSleep(3000, 1000) { @Override public boolean condition() throws InterruptedException { if (!Rock.CLAY.hasOre(rockToMine)) { log("Rock has no ore!"); return true; } else if (!myPlayer().isAnimating()) { log("Animation finished!"); return true; } else { return false; } } }.sleep(); } } When checking the log, the "Rock has no ore!" never appears, which is confusing as I have watched the bot in times when the rock is empty of ore and the animation is still continuing regardless, it never reaches the "Rock has no ore!" output, just only ever outputting "Animation finished", whenever the animation has finished. I also changed the sleep conditional return to myPlayer().isAnimating() to !myPlayer().isAnimating() as wouldn't I want it to return true if the player had stopped animating, to break the sleep conditional?
  4. Yep that's what I thought and was trying to implement with this: new ConditionalSleep(3000, 500) { @Override public boolean condition() throws InterruptedException { return Rock.CLAY.hasOre(rockToMine) && myPlayer().isAnimating(); } }.sleep(); But it still just resulted in the mining animation playing for its full length in almost all cases.
  5. Thanks for the reply, I have actually being using that Explv's code snippet already in this script. So I changed my code to the following: private void mine(String chosenOre) { // Get rock to mine RS2Object rockToMine = getObjects().closest(object -> Rock.CLAY.hasOre(object)); if (!playerAnimating()) { // Check if player is not animating if (rockToMine != null) { // Check if rock is not null if (rockToMine.interact("Mine")) { new ConditionalSleep(3000, 500) { @Override public boolean condition() throws InterruptedException { return Rock.CLAY.hasOre(rockToMine) && myPlayer().isAnimating(); } }.sleep(); } } } } So in the conditional sleep's return I added the the hasOre check to the currently being mined ore, but it doesnt seem to be making a difference, if the rock gets mined by someone else, it just runs the full length of the animation and then tries to select another rock again.
  6. So I've been building a mining script and want a way to check if the rock being mined still exists whilst the player is mining it, say for instance another player manages to mine it before I do and then I can make the bot stop the mining animation and find another rock that has ore it and start mining that. This is my mining function: private void mine(String chosenOre) { // Get rock to mine RS2Object rockToMine = getObjects().closest(object -> Rock.CLAY.hasOre(object)); if (!playerAnimating()) { // Check if player is not animating if (rockToMine != null) { // Check if rock is not null if (rockToMine.interact("Mine")) { new ConditionalSleep(1000, 500) { @Override public boolean condition() throws InterruptedException { return playerAnimating(); } }.sleep(); } } } } What would be the best way to implement the check for if the rock being mined still exists? I have tried putting within the return of the ConditionalSleep return rockToMine != null as a check but I didnt work, which I am assuming is due to the state of the rock being checked, being the original one from when it had ore in at and not the updated state of the rock that is empty? If so how do you get the updated state of the currently selected object, to then check its current state? Thanks in advance for any help.
×
×
  • Create New...