Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Strange behaviour when picking stuff up


    jonis5s

    Recommended Posts

    So I just started scripting for fun, and I got a problem with my script.

    I am trying to make a cowhide looter just to learn the api.

    When the script is trying to pick up a cowhide, sometimes it doesn't seem to realise that the cowhide isn't there anymore, so it just right clicks where the cowhide was before and then loops like this like 3-5 times. This happens probably about one in three times, and it bothers me.

    This is the code that I made for looting:

    case loot:
        log("looting cowhide");
        GroundItem cowhide = getGroundItems().closest("Cowhide");
    
        if (cowhide != null){
            cowhide.interact("Take");
        }
        sleepWhile(() -> getLocalPlayer().isMoving(), 30000);
        break;

    What am I doing wrong?

    Because it's around midnight for me, and I got work tomorrow, I'll hit the bed and check in for answers tomorrow :)

    Link to comment
    Share on other sites

    5 hours ago, Volta said:

     

    
    if (cowhide != null && cowhide.exists()){
            cowhide.interact("Take");
        }

    I tried that, but found that it did the same thing. 

    Link to comment
    Share on other sites

    Interact is a boolean in itself too, try this:

    if (cowhide != null && cowhide.interact("Take") {
     MethodProvider.sleepUntil(() -> !cowhide.exists(), 2000);
    }

     

    Link to comment
    Share on other sites

    I would suggest rather using a sleepUntil.

    Your timeout on ur sleep is also 30 seconds which is unnecessary in this case.

    Try this:

    GroundItem cowhide = getGroundItems().closest("Cowhide");
    if (cowhide != null) {
        cowhide.interact("Take");
        sleepUntil(() -> !cowhide.exists(), 3000);
    }
    Link to comment
    Share on other sites

    13 hours ago, Articron said:

    Interact is a boolean in itself too, try this:

    
    if (cowhide != null && cowhide.interact("Take") {
     MethodProvider.sleepUntil(() -> !cowhide.exists(), 2000);
    }

     

    That really did the trick, thank you!

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.