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.

How do I keep fishing consistently?

Featured Replies

Hey, so I'm pretty new to this, and I have a question..

I'm currently writing a fishing script for fun/learning purposes, and I stumbled upon the fact that my fish() method stops running after achieving a level or when the fishing spot disappears. I know that the script executioner gets called depending on the ms you specify in the onLoop method, and I've also tried adding a while loop, but neither of these methods helped me fix the problem.
 

private void fish() {
    if (!lumbyFishing.contains(myPosition())) {
        getWalking().webWalk(lumbyFishing);
    }

    Entity fishingSpot = getNpcs().closest("Fishing spot");

    while (fishingSpot.exists()) {
        if (fishingSpot != null && fishingSpot.interact("Net")) {
            new Sleep(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000).sleep();
        }
    }
}


SO my question to you guys was: What is wrong with my code?

Thanks in advance.

Edited by Jake Slang

If you level up, or the spot moves, you'll no longer be animating.
Add in an animation check somewhere to determine if you're fishing or not.
 

Then just loop your fishing method.

new Sleep(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000).sleep();

this should be && no?

1 hour ago, Jake Slang said:

Hey, so I'm pretty new to this, and I have a question..

I'm currently writing a fishing script for fun/learning purposes, and I stumbled upon the fact that my fish()  method stops running after achieving a level or when the fishing spot disappears. I know that the script executioner gets called depending on the ms you specify in the onLoop method, and I've also tried adding a while loop, but neither of these methods helped me fix the problem.
 


private void fish() {
    if (!lumbyFishing.contains(myPosition())) {
        getWalking().webWalk(lumbyFishing);
    }

    Entity fishingSpot = getNpcs().closest("Fishing spot");

    while (fishingSpot.exists()) {
        if (fishingSpot != null && fishingSpot.interact("Net")) {
            new Sleep(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000).sleep();
        }
    }
}


SO my question to you guys was: What is wrong with my code?

Thanks in advance.

I don't know anything about coding a script but From website & small java programming I'd use a loop to loop the whole code so that it constantly runs.

Simple way to check for this

if (!myPlayer.isAnimating) {

if (fish!=null) {
fish.interact("Fish");

sleepConditionUntil(myPlayer.isAnimating);

}

} else {
//do nothing

}

 

if (canFish()){
	fish();
}

private boolean canFish(){
return !myPlayer.isAnimating && !getInventory.isFull
}

private void fish(){
if (fishingSpot != null){
	if (fishingSpot.interact("w/e")){
		// Sleep until animating
		}
	}
}

Something like that, you should get the idea :boge: 

  • Author

Thank each one of you for all your efforts. I'll read through after breakfast :doge:

Edited by Jake Slang

9 hours ago, Juggles said:

Simple way to check for this


if (!myPlayer.isAnimating) {

if (fish!=null) {
fish.interact("Fish");

sleepConditionUntil(myPlayer.isAnimating);

}

} else {
//do nothing

}

 

Someone give this guy Scripter II!

  • Author

Ok, so I don't think my code was necessarily wrong, but I did made some adjustments conform your advice:
 

private final Area lumbyFishing = new Area(3247, 3156, 3244, 3154);

public final int onLoop() throws InterruptedException {
    if (canFishShrimps()) {
        fish();
    } else {
        bank();
    }

    return random(150, 200);
}

private void fish() {
    if (!lumbyFishing.contains(myPosition())) {
        getWalking().webWalk(lumbyFishing);
    }

    Entity fishingSpot = getNpcs().closest("Fishing spot");

    if (fishingSpot != null) {
        if (fishingSpot.interact("Net")) {
            sleepConditional();
        }
    }
}

private void sleepConditional() {
    Entity fishingSpot = getNpcs().closest("Fishing spot");

    if (fishingSpot != null && fishingSpot.interact("Net")) {
        Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000);
        log(Sleep.sleepUntil(() -> myPlayer().isAnimating() || !fishingSpot.exists(), 5000));
    }
}

private void bank() {
    //
}

private boolean canFishShrimps() {
    return !myPlayer().isAnimating() && !getInventory().isFull();
}


So I think the problem was that I also had to export my Sleep class (which was automatically created on reference) 
to my Script folder.

PS: And I know I can refactor this logic a lot more; I'm on it! :)

Edited by Jake Slang

16 hours ago, Juggles said:

Simple way to check for this


if (!myPlayer.isAnimating) {

if (fish!=null) {
fish.interact("Fish");

sleepConditionUntil(myPlayer.isAnimating);

}

} else {
//do nothing

}

 

LOL

The main issue was the while(fishingSpot.exists())

A simple fix (Removing the while loop is best though) would be to change the while to something like while(fishingSpot.exists() && myPlayer().getAnimation() != -1)

21 hours ago, YoHoJo said:

If you level up, or the spot moves, you'll no longer be animating.
Add in an animation check somewhere to determine if you're fishing or not.
 

Then just loop your fishing method.

When the spot moves,  your player still animates for a decent 5 seconds afterwards.
You need to check if the object still exists if you want maximum efficiency

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.