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
  • Try asking for help in the chatbox
  • Games necklace(*) interacting in Inventory


    xVril
     Share

    Recommended Posts

    A Games necklace can have various charges meaning its Integer ID and String name change.

    I have tried to handle the various IDs/ names the Item can have by using a Filter as follows:

    		if (s.getInventory().contains(Filters.GAMES_NECKLACE_FILTER)) {
    			if (s.getInventory().interact(Filters.GAMES_NECKLACE_FILTER, "Rub")) {
    				MethodProvider.sleep(1000, 2000);
    				s.getKeyboard().type("1", false);
    				return true;

    It is able to verify that the Inventory contains a Games necklace but it is unable to interact with it. Any solutions?

    public static final Filter<Item> GAMES_NECKLACE_FILTER = item -> item.getName().contains("Games necklace");

     

    Link to comment
    Share on other sites

    Solution is the below, was thinking there might be an easier way to do it.

    		if (s.getInventory().contains(Filters.GAMES_NECKLACE_FILTER)) {	
    			for(Item i : s.getInventory().all())
    				if(i != null && Filters.GAMES_NECKLACE_FILTER.match(i)) {
    					s.getInventory().interact(i.getName(), "Rub");
    					MethodProvider.sleep(1000, 2000);
    					s.getKeyboard().type("1", false);		
    					return true;
    				}

     

    Link to comment
    Share on other sites

    Nice job on finding a solution, but you shouldn't have to iterate over the whole inventory. Something such as the following ought to work to suit:

     

       Item gamesNecklace = getInventory().get(i -> i.getName().contains("Games necklace("));
            if (gamesNecklace != null) {
                if (teleportOptionsDialog != null) { //pseudo code
                    teleportOptionsDialog.interact("string");
                    sleepUntil(() -> !teleportOptionsDialog.isVisible(), 3000);
                } else {
                    if (gamesNecklace.interact("Rub")) {
                        sleepUntil(() -> teleportOptionsDialog != null, 3000);
                    }
                }
            }
    Edited by Pseudo
    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
     Share

    ×
    ×
    • 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.