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
  • How do i use sleepUntil?


    wkmac

    Recommended Posts

    This is my current code for it

    public void shoot() {
    if (getTabs().isOpen(Tab.INVENTORY)) {
    Inventory inventory = getInventory();
    Item arrows = inventory.get("Bronze arrow");
    if(arrows != null){
    arrows.interact();
    }
    getTabs().openWithFKey(Tab.COMBAT);
    } else {
    getTabs().open(Tab.INVENTORY);
    Inventory inventory = getInventory();
    Item arrows = inventory.get("Bronze arrow");
    if(arrows != null){
    arrows.interact();
    getTabs().openWithFKey(Tab.COMBAT);
    }
    }
    getWalking().walk(new Tile(2670, 3418, 0));
    
    int i;
    for (i = 0; i < 10; i++)
    getCamera().mouseRotateToEntity(getGameObjects().closest("Target"));
    getGameObjects().closest("Target").interactForceRight("Fire-at");
    sleepUntil(() -> getWidgets().getWidget(325).isVisible(), 3000);
    if(getWidgets().getWidget(593) != null){
    getWidgets().getWidget(593).getChild(28).interact();
    }
    
    state = 0;
    }

    Im not sure whether im having the issue in the code but here are the exceptions that are thrown

    [ERROR]12:49:21: Exception has occurred while running! Please report error to developer if problem persists:
    	java.lang.NullPointerException
    	at main.Main.lambda$shoot$0(Main.java:92)
    	at org.dreambot.api.methods.MethodProvider.sleepUntil(MethodProvider.java:75)
    	at main.Main.shoot(Main.java:92)
    	at main.Main.onLoop(Main.java:43)
    	at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:223)
    	at java.lang.Thread.run(Unknown Source)
    
    [ERROR]12:49:23: Exception has occurred while running! Please report error to developer if problem persists:
    	java.lang.NullPointerException
    	at main.Main.shoot(Main.java:83)
    	at main.Main.onLoop(Main.java:43)
    	at org.dreambot.api.script.AbstractScript.run(AbstractScript.java:223)
    	at java.lang.Thread.run(Unknown Source)
    
    Link to comment
    Share on other sites

    Not entirely sure if this is the issue, but try adding:  getWidgets().getWidget(325)!= null to your condition

     

    sleepUntil(() -> getWidgets().getWidget(325)!= null  && getWidgets().getWidget(325).isVisible(), 3000);

    Link to comment
    Share on other sites

    Not entirely sure if this is the issue, but try adding:  getWidgets().getWidget(325)!= null to your condition

     

    sleepUntil(() -> getWidgets().getWidget(325)!= null  && getWidgets().getWidget(325).isVisible(), 3000);

     

    is the long as the second argument the timeout value?

    Link to comment
    Share on other sites

    is the long as the second argument the timeout value?

    Yes, your first argument is the boolean statement that you want to wait until its true, but your second argument is how long you will wait to break out of the sleep even if the boolean isnt true.

    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.