Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Blocking events

Featured Replies

I'm writing my first script which is for fishing and I'm wondering if there are any classes/methods in the api that can provide blocking events? If you have no clue what I'm talking about take for example this code
 

        @Override
        public void forceState(Script script) throws Exception {
 
            /** Move toward wherever the bank is. */
            script.setRunning(true);
            FishingScript.getBankLocation().getPosition().walkMinimap(script.myPlayer().getBot());
 
            /** Get the nearest bank and open it. */
            RS2Object object = script.closestObject(FishingScript.getBankLocation().getObjectId());
            object.interact("Bank");
 
            /** Deposit all items except for the fishing tools. */
            script.myPlayer().getClient().getBank().depositAllExcept(FishingScript.getFishingType().getBankException());
        }

if I tried to execute that all at once the script would try and click the bank before I was even at the position, deposit the items before the bank was even opened, etc. etc.

 

so I was wondering if there are any functions that serve a purpose like this, where the thread would block until the operation was completed?

 

            @Override
            public void forceState(Script script) throws Exception {
 
                /** Move toward wherever the bank is. */
                new BlockingEvent() {
                    @Override
                    public boolean blockUntil() {
                        return !script.myPlayer().isMoving();
                    }
                    
                    @Override
                    public void run() {
                        script.setRunning(true);
                        FishingScript.getBankLocation().getPosition().walkMinimap(script.myPlayer().getBot());
                    }
                }.start();
 
                /** Get the nearest bank and open it. */
                new BlockingEvent() {
                    @Override
                    public boolean blockUntil() {
                        return !script.myPlayer().getClient().getBank().isOpen();
                    }
                    
                    @Override
                    public void run() {
                        script.setRunning(true);
                        FishingScript.getBankLocation().getPosition().walkMinimap(script.myPlayer().getBot());
                    }
                }.start();
 
                /** Deposit all items except for the fishing tools. */
                new BlockingEvent() {
                    @Override
                    public boolean blockUntil() {
                        return !script.myPlayer().getClient().getInventory().isFull();
                    }
                    
                    @Override
                    public void run() {
                        script.myPlayer().getClient().getBank().depositAllExcept(FishingScript.getFishingType().getBankException());
                    }
                }.start();
            }
I have no problem designing something myself if needed, this is my first script so I have no clue if that's even how its supossed to be done. If anyone more experienced can point me in the right direction that would be cool.
 
thanks

Edited by lare96

Lol, this was a bit funny. Naw what you need to do is use if than and else statement so you you block out, and do what you want to do.

Example:

If my player isn't at bank at bank area then walk to bank.

Else if my player is there and bank is not opened then open it.

Blah blah blah

  • Author

Lol, this was a bit funny. Naw what you need to do is use if than and else statement so you you block out, and do what you want to do.

Example:

If my player isn't at bank at bank area then walk to bank.

Else if my player is there and bank is not opened then open it.

Blah blah blah

i dont see how that was funny at all but okay

 

thanks

I'm slightly confused what you're going for here, but if I'm correct just simple conditional checks should suffice for executing code when a specific condition is met :p

I'm slightly confused what you're going for here, but if I'm correct just simple conditional checks should suffice for executing code when a specific condition is met tongue.png

thats exactlly what he needs

  • Author

sorry, I'm new to script development :P but yeah you guys were right the script I made works great! Thanks

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.