Jump to content

Abort offer if it has ... status


The Undefeated

Recommended Posts

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
Link to comment
Share on other sites

1 minute ago, Token said:

If you are looking for improvements I guess you could start by removing any constant number that you can't justify ("magic numbers" in programming), I see at least 4 of them in the 2nd method, and another 2 which will make your code unstable

 G.E. Box 1 has widget number 7, Box 2 has 8 etc. That's why.

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Just now, Token said:

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.

300 looks better than 301, shaboom.

Srslly tho, what token said.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 3 weeks later...

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.

  • Recently Browsing   0 members

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