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.

Two quick questions

Featured Replies

Ok so here's the part of the code I need help on.

 

private State getState() 
{
if(!myPlayer().isAnimating() && !inventory.isFull())
{
return State.FISH;
}
if(inventory.isFull())
{
return State.DROP;
}
return State.WAIT;
}
 
public int onLoop() throws InterruptedException 
{
switch (getState()) 
{
case FISH:
NPC fishingspot = npcs.closest("Fishing Spot");
fishingspot.interact("Net");
break;
 
case DROP:
if(inventory.isFull())
{
inventory.dropAllExcept("Small fishing net");
}
break;
 
My first question is if it benefits or does the same thing if I put the if statement in the case. As seen in the drop case or can I just leave it out and it will execute the same way since it already declared it needed to drop.
 
Second question is for some reason my player drops the fish fairly slow then after it's all dropped stands around for 10 seconds then goes back to fishing, any fix for these?
 
Thanks :)

If im understanding you, you are asking if its necessary to have:

 

if(inventory.isFull())
{
return State.DROP;
}

 

 

 

and then again have this: 

 

case DROP:
if(inventory.isFull())
{
inventory.dropAllExcept("Small fishing net");
}
break;

 

?

 

If that is your question, then its not really necessary. What you are doing could be called "Defensive programming". Basically its checking the crap out of everything to make sure that its what you want, which prevents any unwanted results or nulls etc. I am not a fan of state based scripting, I always use task based. Case gets too messy imo, but thats just me. ^_^

  • Author

Yeah that was it, thank you for the answer smile.png, what is task based if it's not to hard to explain.

 

Also does anyone know why my character drops fish slow then stands around for 10 seconds doing nothing until it starts to fish again?

Edited by Snowydell

Yeah that was it, thank you for the answer smile.png, what is task based if it's not to hard to explain.

 

Also does anyone know why my character drops fish slow then stands around for 10 seconds doing nothing until it starts to fish again?

 

 

Oh yea, dropAll is a slow action. There isnt a way to fix it that I know of other than writing your own method.

  • Author

Learn some Java first then go to the tutorial section and use one of the tutorials as a base. You could learn the basics of Java in less than a week.


Also, it looks confusing because of the way I copy and pasted it so the format is messed up, hard to read

 

 

 

as for the dropping you could try something like:

void dropAllExceptA(String...names) throws InterruptedException {
        if(Tab.INVENTORY.isOpen(this.bot)){
            for(int i = 1; i < 29; i++){
                Item item = inventory.getItemInSlot(i);
                if(item != null && !item.getName().equals(names)){
                    item.interact("Drop");
                    sleep((long) random(0, 0));
                }
            }
        }else{
            tabs.open(Tab.INVENTORY);
            sleep((long) random(0, 0));
        }
    }

    void dropAllExceptB(String...names) throws InterruptedException {
        if(Tab.INVENTORY.isOpen(this.bot)){
           Item[] items = inventory.getItems();
            if(items != null) {
                for (int i = 0; i < items.length; i++) {
                      Item item = items[i];
                    if (item != null && !item.getName().equals(names)) {
                        item.interact("Drop");
                        sleep((long) random(0, 0));
                    }
                }
            }
        }else{
            tabs.open(Tab.INVENTORY);
            sleep((long) random(0, 0));
        }
    }

i dont actually know if there's alot of difference between the methods but you could alter the length of sleeps to make it quicker

Yes i wrote 29.

  • Author

as for the dropping you could try something like:

void dropAllExceptA(String...names) throws InterruptedException {
        if(Tab.INVENTORY.isOpen(this.bot)){
            for(int i = 1; i < 29; i++){
                Item item = inventory.getItemInSlot(i);
                if(item != null && !item.getName().equals(names)){
                    item.interact("Drop");
                    sleep((long) random(0, 0));
                }
            }
        }else{
            tabs.open(Tab.INVENTORY);
            sleep((long) random(0, 0));
        }
    }

    void dropAllExceptB(String...names) throws InterruptedException {
        if(Tab.INVENTORY.isOpen(this.bot)){
           Item[] items = inventory.getItems();
            if(items != null) {
                for (int i = 0; i < items.length; i++) {
                      Item item = items[i];
                    if (item != null && !item.getName().equals(names)) {
                        item.interact("Drop");
                        sleep((long) random(0, 0));
                    }
                }
            }
        }else{
            tabs.open(Tab.INVENTORY);
            sleep((long) random(0, 0));
        }
    }

i dont actually know if there's alot of difference between the methods but you could alter the length of sleeps to make it quicker

Yes i wrote 29.

Hm let me try that 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.