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
  • missclicks when equiping items.


    smh1

    Recommended Posts

    Hello again! I wrote a pretty simple task for the bot to equip his gear. And noticed it's very inconsistent - keeps missclicking and when whe finally manages to equip the gear if he missclicks on the last items he just sleeps.

     if (Inventory.contains(SPIKED_MANACLES, COMBAT_BRACELET, AMULET_OF_GLORY, IRON_SCIMMY, IRON_SET_LG, WARRIOR_RING) && !GrandExchange.isOpen() || Inventory.contains(IRON_SHIELD, IRON_HELM, IRON_BODY, IRON_LEGS) && !GrandExchange.isOpen()) {
                log("Equiping starter pack");
                if (Inventory.contains(IRON_SET_LG)) {
                    sleep(650, 1500);
                    geClerk.interact("Sets");
                    sleepUntil(() -> Widgets.isOpen(), 2000);
                    sleep(550, 1000);
                    Inventory.get(IRON_SET_LG).interact();
                    sleepUntil(() -> Inventory.contains(IRON_SHIELD), 1000, 2000);
                    Widgets.closeAll();
                    sleepUntil(() -> !Widgets.isOpen(), 2000);
                }
                if (!Equipment.contains(IRON_HELM)) {
                    Inventory.get("Iron full helm").interact("Wear");
                    sleepUntil(() -> Equipment.contains(IRON_HELM), 150, 500);
                }
                if (!Equipment.contains(IRON_SCIMMY)) {
                    Inventory.get(IRON_SCIMMY).interact();
                    sleepUntil(() -> Equipment.contains(IRON_SCIMMY), 150, 500);
                }
                if (!Equipment.contains(COMBAT_BRACELET)) {
                    Inventory.get(COMBAT_BRACELET).interact("Wear");
                    sleepUntil(() -> Equipment.contains(COMBAT_BRACELET), 150, 500);
                }
                if (!Equipment.contains(WARRIOR_RING)) {
                    Inventory.get(WARRIOR_RING).interact("Wear");
                    sleepUntil(() -> Equipment.contains(WARRIOR_RING), 150, 350);
                }
                if (!Equipment.contains(AMULET_OF_GLORY)) {
                    Inventory.get(AMULET_OF_GLORY).interact("Wear");
                    sleepUntil(() -> Equipment.contains(AMULET_OF_GLORY), 550, 1050);
                }
                if (!Equipment.contains(SPIKED_MANACLES)) {
                    Inventory.get(SPIKED_MANACLES).interact("Wear");
                    sleepUntil(() -> Equipment.contains(SPIKED_MANACLES), 150, 350);
                }
                if (!Equipment.contains(IRON_BODY)) {
                    Inventory.get(IRON_BODY).interact("Wear");
                    sleepUntil(() -> Equipment.contains(IRON_BODY), 150, 350);
                }
                if (!Equipment.contains(IRON_LEGS)) {
                    Inventory.get(IRON_LEGS).interact("Wear");
                    sleepUntil(() -> Equipment.contains(IRON_LEGS), 150, 350);
                }
                if (!Equipment.contains(IRON_SHIELD)) {
                    Inventory.get(IRON_SHIELD).interact();
                    sleepUntil(() -> Equipment.contains(IRON_SHIELD), 150, 350);
                }
            }
            return 300;
        }
    }

    image.png.b4a2566bbd45d116a0b422944e4339d4.png

    Link to comment
    Share on other sites

    • 2 weeks later...

    Just write a function that "safely" equips everything. I.e. it loops attempting to equip it until it is equipped. Also ensure your sleep timeout is in milliseconds (long time)

    Link to comment
    Share on other sites

    I would start with writing a function that ensures that desired item is equipped - You're doing the same thing over and over so why not cut a corner to save some lines?

    private boolean EnsureEquipped(int id) {
    	if (!Equipment.contains(id)) {
    		if (Inventory.contains(id) && Inventory.get(item) != null && Inventory.get(item).interact()) {
    			sleepUntil(() -> Equipment.contains(id), 1500, 3000);
    			return true;
    		}
    	} else {
    		return true; 
    	}
    	return false;
    }

    Then whenever needed in loop just call

    if (EnsureEquipped(IRON_SHIELD) && EnsureEquipped(IRON_HELM) && EnsureEquipped(IRON_SCIMMY)) {
      // Do something when all of the items are equipped
    } else {
      // Grab items from bank or buy them
    }

     

    Notice that interact() function returns a boolean - it looks like it returns true if it has actually clicked, so it seems like a good idea to check if we have actually clicked before firing any sleep events.

    With Your code it attempted to click with mostly failed result (returned false), so the code went to next line which waited for equipment to be in place, but the script didn't actually click the item so there was no wait. Above function will only wait for the item to be equipped AFTER clicking the item with a success. Also, increasing the minimum wait is needed here, as we need time for the client to actually hop the item from inventory to equipment.

    So using above function and Your example, we could build something like this

    if (EnsureEquipped(SPIKED_MANACLES) &&
        EnsureEquipped(COMBAT_BRACELET) &&
        EnsureEquipped(AMULET_OF_GLORY) &&
        EnsureEquipped(IRON_SCIMMY) &&
        EnsureEquipped(IRON_PLATEBODY) &&
        EnsureEquipped(IRON_PLATELEGS) &&
        EnsureEquipped(IRON_FULL_HELM) &&
        EnsureEquipped(IRON_KITESHIELD) &&
        EnsureEquipped(WARRIOR_RING)) 
    {
    	// Do something
    } else {
    	// Some parts were missing, we can log that we didn't match all of the requirements here 
    }

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • 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.