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.

Script only banks

Featured Replies

Hello I'm new around here and I'm trying to learn how to script.

I want to give something to the community but I have to learn to code first ;)

My problems:

  • I have to have a small fishing net in my inventory or it wont open bank and get one
  • If I have a small fishing net it opens bank then closes then opens and continues like that
	private enum State {
		FISH, BANK, WAIT
	};

	private State getState() {
		Entity stall = objects.closest("Fishing spot");
		if (inventory.isEmpty() && !inventory.contains("Small fishing net"))
			return State.BANK;
		if (stall != null && inventory.contains("Small fishing net"))
			return State.FISH;
		return State.WAIT;
	}

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case FISH:
			Entity spot = objects.closest("Fishing spot");
			if (spot != null) {
				inventory.interact("Use", "Small Fishing Net");
				if (inventory.isItemSelected() == true)
				spot.interact();
			}
			break;
		case BANK:
			Entity bank = objects.closest("Bank booth");
			if (!inventory.contains("Small fishing net"))
				getBank().withdraw("Small fishing net", 1);
			if (bank != null) {
				bank.interact("Bank");
				sleep(random(500, 700));
				getBank().depositAllExcept("Small fishing net");
			}
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
		return random(200, 300);
	}

Edited by nickeb0i

Where abouts are you fishing? You haven't created a path way to get to the bank.

Entity bank = objects.closest("Bank booth");

That will only pick up a bank thats within range of your camera angle :/

Edited by Kenn

  • Author

Where abouts are you fishing? You haven't created a path way to get to the bank.

Entity bank = objects.closest("Bank booth");

That will only pick up a bank thats within range of your camera angle :/

 

Are you sure? I think you mean if it's in a range within the minimap? :)

  • Author

The fishing spot is a NPC, and not an object.

 

It doesn't even get to the point where it should go to the fishing spot and fish? :/

It doesn't even get to the point where it should go to the fishing spot and fish? :/

 

Alright here in pseudo-code:

NPC spot = get NPC's nearby with a filter which have the name "Fishing spot" and have an action called "Net"
 
if (spot is not null)
 
if (spot is visible on our screen)
 
interact with the spot with action "Net"
 
else // so the spot isnt visible
walk to the spot

This isn't really pseudo-code, but it serves the purpose.

Edited by KEVzilla

 

Hello I'm new around here and I'm trying to learn how to script.

I want to give something to the community but I have to learn to code first wink.png

My problems:

  • I have to have a small fishing net in my inventory or it wont open bank and get one
  • If I have a small fishing net it opens bank then closes then opens and continues like that
	private enum State {
		FISH, BANK, WAIT
	}

	private State getState() {
		Entity stall = objects.closest("Fishing spot");
		if (inventory.isEmpty() && !inventory.contains("Small fishing net"))
			return State.BANK;
		if (stall != null && inventory.contains("Small fishing net"))
			return State.FISH;
		return State.WAIT;
	}

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case FISH:
			Entity spot = objects.closest("Fishing spot");
			if (spot != null) {
				inventory.interact("Use", "Small Fishing Net");
				if (inventory.isItemSelected() == true)
				spot.interact();
			}
			break;
		case BANK:
			Entity bank = objects.closest("Bank booth");
			if (!inventory.contains("Small fishing net"))
				getBank().withdraw("Small fishing net", 1);
			if (bank != null) {
				bank.interact("Bank");
				sleep(random(500, 700));
				getBank().depositAllExcept("Small fishing net");
			}
			break;
		case WAIT:
			sleep(random(500, 700));
			break;
		}
		return random(200, 300);
	}

 

Fishing spot is an NPC.

 

Also use the built in bank method:

if(!getBank().isOpen()){

    getBank().open();
    new ConditionalSleep(5000) {
        @Override
        public boolean condition() throws InterruptedException {
            return getBank().isOpen();
        }
    }.sleep();
} else if (!inventory.contains("Small fishing net")){
    getBank().withdraw("Small fishing net", 1);
} else {
    getBank().depositAllExcept("Small fishing net");
}
 

Also in your getState() method, State.BANK will not return if you have a full inventory.

You only bank when your inventory is empty.

if (inventory.isEmpty() && !inventory.contains("Small fishing net")){
    return State.BANK;
}

It should be:

if (inventory.isFull() || !inventory.contains("Small fishing net")){
    return State.BANK;
}

As a result of this, your WAIT state is redundant:

private enum State {
    FISH, BANK
}

private State getState() {

    if (inventory.isFull() || !inventory.contains("Small fishing net")){
	return State.BANK;
    }
    return State.FISH;
}
		
@Override
public int onLoop() throws InterruptedException {
    switch (getState()) {
	case FISH:
	    NPC spot = getNpcs().closest("Fishing spot");
	    if (spot != null) {
		spot.interact("Net");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return myPlayer().isAnimating();
                    }
                }.sleep();
            }
	    break;
	case BANK:
            if(!getBank().isOpen()){

                getBank().open();
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getBank().isOpen();
                    }
                }.sleep();
            } else if (!inventory.contains("Small fishing net")){
                getBank().withdraw("Small fishing net", 1);
            } else {
                getBank().depositAllExcept("Small fishing net");
            }
	    break;
    }		
    return random(200, 300);
}

To prevent spam clicking you may then want to wrap your onLoop code with a condition, where the script does nothing if the player is animating or moving:

private enum State {
    FISH, BANK
}

private State getState() {

    if (inventory.isFull() || !inventory.contains("Small fishing net")){
	return State.BANK;
    }
    return State.FISH;
}
		
@Override
public int onLoop() throws InterruptedException {

    if(!myPlayer().isAnimating() && !myPlayer().isMoving()){

        switch (getState()) {

	    case FISH:
	        NPC spot = getNpcs().closest("Fishing spot");
	        if (spot != null) {
		    spot.interact("Net");
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return myPlayer().isAnimating();
                        }
                    }.sleep();
                }
	        break;
	    case BANK:
                if(!getBank().isOpen()){

                    getBank().open();
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return getBank().isOpen();
                        }
                    }.sleep();
                } else if (!inventory.contains("Small fishing net")){
                    getBank().withdraw("Small fishing net", 1);
                } else {
                    getBank().depositAllExcept("Small fishing net");
                }
	        break;
        }		
    }
    return random(200, 300);
}

You will also need to handle the case where the bank does not contain a fishing net.

 

You may also want to include paths to and from the bank and fishing spot:

Area fishingArea = new Area(0, 0, 0, 0); // Define this
Area bankArea = new Area(0, 0, 0, 0); // Define this
Position[] pathToBank = new Position[]{ }; // Define this
Position[] pathToSpot = new Position[]{ }; // Define this

private enum State {
    FISH, BANK, WALK_TO_BANK, WALK_TO_SPOT
}

private State getState() {

    if (inventory.isFull() || !inventory.contains("Small fishing net")){

        if(bankArea.contains(myPosition())) return State.BANK;
        return State.WALK_TO_BANK;
    }

    if(!fishingArea.contains(myPosition())) return State.WALK_TO_SPOT;

    return State.FISH;
}
		
@Override
public int onLoop() throws InterruptedException {

    if(!myPlayer().isAnimating() && !myPlayer().isMoving()){

        switch (getState()) {

	    case FISH:
	        NPC spot = getNpcs().closest("Fishing spot");
	        if (spot != null) {
		    spot.interact("Net");
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return myPlayer().isAnimating();
                        }
                    }.sleep();
                }
	        break;
	    case BANK:
                if(!getBank().isOpen()){

                    getBank().open();
                    new ConditionalSleep(5000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return getBank().isOpen();
                        }
                    }.sleep();
                } else if (!inventory.contains("Small fishing net")){

                    if(getBank().contains("Small fishing net")) getBank().withdraw("Small fishing net", 1);
                    else stop(true);
                } else {
                    getBank().depositAllExcept("Small fishing net");
                }
	        break;

            case WALK_TO_BANK:
                getLocalWalker().walkPath(pathToBank);
                break;
            case WALK_TO_SPOT:
                getLocalWalker().walkPath(pathToSpot);
                break;
        }		
    }
    return random(200, 300);
}

doge.png

Edited by Explv

  • Author

 

Fishing spot is an NPC.

 

Also use the built in bank method:

if(!getBank().isOpen()){

    getBank().open();
    new ConditionalSleep(5000) {
        @Override
        public boolean condition() throws InterruptedException {
            return getBank().isOpen();
        }
    }.sleep();
}

 

Thank you very much, been looking for this :)

 

Thank you very much, been looking for this smile.png

 

 

See my updated post, there are more errors tongue.png

Edited by Explv

  • Author

See my updated post, there are more errors tongue.png

 

Thank you, how do I fix this

        case FISH:
            Entity spot = objects.closest("Fishing spot");
            if (spot != null) {
                inventory.interact("Use", "Small Fishing Net");
                if (inventory.isItemSelected() == true)
                spot.interact();
            }

so it recognizes fishing spot as a NPC?

Thank you, how do I fix this

        case FISH:
            Entity spot = objects.closest("Fishing spot");
            if (spot != null) {
                inventory.interact("Use", "Small Fishing Net");
                if (inventory.isItemSelected() == true)
                spot.interact();
            }

so it recognizes fishing spot as a NPC?

 

See updated post.

 

  • Author

See updated post.

 

 

Thank you so much :D Now it works, just gonna figure out how to do a walking path and a GUI.

Thank you so much biggrin.png Now it works, just gonna figure out how to do a walking path and a GUI.

 

There exist builders for GUI's. And for a path, if you need it.. Here's a simple Path Maker: http://dunnkers.github.io/DunkPathMaker/

Edited by KEVzilla

Create an account or sign in to comment

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.