Jump to content

Abort offer if it has ... status


Recommended Posts

Posted (edited)

Simple snippet to abort all offers if they have status x.

    private boolean toAbortOffers() {
        return !getWidgets().containingActions(465,"Abort offer").isEmpty();
    }

    private void abortOffers() throws InterruptedException {
        if (toAbortOffers()) {
            ArrayList<RS2Widget> toAbort = (ArrayList<RS2Widget>) getWidgets().containingActions(465,"Abort offer");
            for (int i = 0; i < toAbort.size(); i++) {
                toAbort.get(i).interact("Abort offer");
                int finalI = i;
                new ConditionalSleep(10000) {
                    @Override
                    public boolean condition() {
                        return Arrays.asList(toAbort.get(finalI).getInteractOptions()).contains("Abort offer");
                    }
                }.sleep();
            }
            sleep(random(800,1200));
            getGrandExchange().collect();
        }
    }

If you see any improvements I could make, don't hesitate to comment.

 

https://gyazo.com/bf50191011b0d8fd69b67ae4ea55da53

Edited by The Undefeated
  • Like 2
Posted
Just now, The Undefeated said:

Please tell me how I could improve that?

Other one must be the static widget (Which is almost impossible to replace or the sleep.

 

I don't see why it's impossible to replace, the id is just one of the many properties a RS2Widget object has. Take a look through all methods, there's at least 10 different ways of identifying a widget and id is only 1 of them (easiest and worst at the same time) https://osbot.org/api/org/osbot/rs07/api/ui/RS2Widget.html

eg: filter by actions, filter by position, filter by message, filter by color BUT NOT filter by id. The simple reason behind this is the properties I mentioned are all exposed to the human player, while abstract numbers such as ids and indexes are not visible to normal players, and jagex can change them whenever they want without affecting the legit players. They do this about once a month for the tutorial island widgets just to break all scripts coded by people who use these properties. 

As for the sleeps, if I ask you why 300 and not 301, and you can't give a serious answer to this, then it is an obviously flawed logic. A better approach would be waiting until something happens aka conditional sleep.

  • Like 4
Posted (edited)
1 hour ago, Token said:

I don't see why it's impossible to replace, the id is just one of the many properties a RS2Widget object has. Take a look through all methods, there's at least 10 different ways of identifying a widget and id is only 1 of them (easiest and worst at the same time) https://osbot.org/api/org/osbot/rs07/api/ui/RS2Widget.html

eg: filter by actions, filter by position, filter by message, filter by color BUT NOT filter by id. The simple reason behind this is the properties I mentioned are all exposed to the human player, while abstract numbers such as ids and indexes are not visible to normal players, and jagex can change them whenever they want without affecting the legit players. They do this about once a month for the tutorial island widgets just to break all scripts coded by people who use these properties. 

As for the sleeps, if I ask you why 300 and not 301, and you can't give a serious answer to this, then it is an obviously flawed logic. A better approach would be waiting until something happens aka conditional sleep.

Thanks for clearing this up, I improved it. Only part I don't like is the sleep before collecting. If I don't add it, the last 1-2 items that were aborted won't be collected.

And it also presses the same exact position on all of the boxes.

 

 

Edited by The Undefeated
  • 3 weeks later...

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...