Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Red_Spark

Item/Noted option in Bank

Recommended Posts

A small snippet that selects the Item or Noted option in bank.

If notedOn = true ,it will enable Noted in bank

notedOn  = false ,it will enable Item in bank

UPDATE:

  • Added a fail safe for the click loop(times out after 10 sec)
  • Now scanning for the interface via Text(that method should be moved outside and only called one pet bot run or when the interface needs to be updated)

Using Entity Selector by laniax please download it and import it.

Topic: 

GitRepo: https://github.com/Laniax/Entity-Selector

 

public static boolean setNoted(boolean notedOn) {

        //Getting Note button state
        RSVarBit varBit = RSVarBit.get(3958);
        if (varBit == null) {
            General.println("VarBit null for Item/Noted");
            return false;
        }

        //Setting noted button to on/off
        if (varBit.getValue() == (notedOn ? 1 : 0)) {
            //It's already set to on/off
            return true;
        }

        //Getting the Item/Note button interface
        RSInterface button = Entities.find(InterfaceEntity::new)
                .inMaster(12)
                .textEquals(notedOn ? "Note" : "Item")
                .getFirstResult();


        if (button == null) {
            General.println("Item/Note button interface is null");
            return false;
        }


        //Trying to click on the Item/Note button
        int buttonClickAttempts = 0;
        long loopFailSafe = Timing.currentTimeMillis();
        while (!Clicking.click(button)) {
            buttonClickAttempts++;
            General.sleep(500, 1000);

            if (buttonClickAttempts >= General.random(3, 5)) {
                General.println("Too many failed attempts to click Item/Note button");
                return false;
            }
            if(Timing.timeFromMark(loopFailSafe) > 10000){
                General.println("Method timed out after 10+sec");
                return false;
            }

        }

        //Fail safe check if we really set Item/Note
        return Timing.waitCondition(() -> varBit.getValue() == (notedOn ? 1 : 0), General.random(2000, 3000));


    }

Happy Coding!

Edited by Red_Spark

Share this post


Link to post
Share on other sites

This is being nitpicky, but there are two things I would suggest changing:

  • RSInterface button = Interfaces.get(
                    notedOn ? 12 : 12,
                    notedOn ? 25 : 23);
    • The use of static Interface child IDs will likely cause the snippet to break after a short time due to game updates changing these IDs, even when the Interface was not changed. Instead I recommend searching interfaces under the root 12 by texture/text/actions and caching it once per script run. If you need a way to do this, Laniax has an excellent Entity Selector API that can make this a breeze.
  •         while (!Clicking.click(button)) {
    
    • Infinite while loops are always dangerous, this task in particular would be better handled by a for loop. If you do need to use a while loop, I'd highly recommend using some sort of timeout. The simplest way to do this is to declare something like "long timeout = System.currentTimeMillis() + 30000;" and adding that as a && part of your while loop. That way as long as time itself does not stop, your script won't get stuck forever if something goes wrong.
       
  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, Netami said:

This is being nitpicky, but there are two things I would suggest changing:

  • RSInterface button = Interfaces.get(
                    notedOn ? 12 : 12,
                    notedOn ? 25 : 23);
    • The use of static Interface child IDs will likely cause the snippet to break after a short time due to game updates changing these IDs, even when the Interface was not changed. Instead I recommend searching interfaces under the root 12 by texture/text/actions and caching it once per script run. If you need a way to do this, Laniax has an excellent Entity Selector API that can make this a breeze.
  •         while (!Clicking.click(button)) {
    
    • Infinite while loops are always dangerous, this task in particular would be better handled by a for loop. If you do need to use a while loop, I'd highly recommend using some sort of timeout. The simplest way to do this is to declare something like "long timeout = System.currentTimeMillis() + 30000;" and adding that as a && part of your while loop. That way as long as time itself does not stop, your script won't get stuck forever if something goes wrong.
       

Interface wise i was always looking for a nicer solution thank for that.What i was doing is having a database interfaces that I use for all my bots.So if something changed i would only need to change one value to fix it for all my scripts :).With your idea i can add some self correcting code to scan for the interface via text/action... and update the database value.

The while loop is not infinite.It breaks out if the bot miss-clicks 3-5 times.But adding the timeout as a fail-safe is not a bad idea.I'll do that from now on :)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 30 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 74 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...