Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Can't get my Fishing Bot to fish [SOLVED]


    UnusualPerson

    Recommended Posts

    Hi Friends!

    I started writing a fishing script today. I've got everything down (dropping, walking), but I can't get it to fish. Whenever I try new code it crashes immediately. Can someone help me. I have read and used almost everything from other people who had this problem, but it wouldn't help. (I am not the best programmer, so I might have misused somethings)

    Edited by UnusualPerson
    Problem has been solved!
    Link to comment
    Share on other sites

    12 minutes ago, UnusualPerson said:

    but I can't get it to fish. Whenever I try new code it crashes immediately.

    post code so we can figure out whats wrong with it.

    Link to comment
    Share on other sites

    20 minutes ago, camalCase said:

    post code so we can figure out whats wrong with it.

    Area BarbarianVillageSpot = new Area(3106, 3434, 3104, 3432);
    private enum State {
        FISH, DROP
    }
    
    private State getState() {
        if (Inventory.contains(Feather, FlyFishingRod) && !Inventory.contains(RawSalmon, RawTrout) &&
                BarbarianVillageSpot.contains(getLocalPlayer())) {
            return State.FISH;
        }
        if (Inventory.isFull() {
            return State.DROP;
        }
    case FISH:
                    log("About to reel in some fish");
    
                    NPC FishingSpot1 = NPCs.closest(f -> f != null && f.getName().contentEquals("Fishing spot") && BarbarianVillageSpot.contains(f));
                    FishingSpot1.interact("Lure");
                    sleep(10000);
    
    //                        NPC fishingSpot = NPCs.closest("Rod Fishing spot");
    
    //                        if (FishingSpot != null) {
    //                            FishingSpot.interact("Lure");
    //                        }
    //                        sleep(10000);
    
    //                        if (fishingSpot != null ) {
    //                            fishingSpot.interact("Lure");
    //                            sleep(600);
    //                        }
    
    
    //                        if (!BarbarianVillageSpot.contains(getLocalPlayer())) {
    //                            Walking.walk(BarbarianVillageSpot.getRandomTile());
    //                            sleepUntil(() -> !getLocalPlayer().isMoving(), 2000);
    //                        }
    //                        if (BarbarianVillageSpot.contains(getLocalPlayer())) {
    //                            if (FishingSpot.isOnScreen()) {
    //                                FishingSpot.interactForceLeft("Lure");
    //                                log("Fishing until Full Inventory.");
    //                            }
    //                        }
    

    This is what I have tried latest, still doesn't do anything. It won't post the log message (About to reel in some fish) in the console.

    The code commented is code I have tried before.

     

    Link to comment
    Share on other sites

    the code in fish case looks okay, if its not logging "about to reel in some fish" it would have to be a problem in your get state method,

     before the if statements in getState(),  write a log() for each of those conditions and see if they're all true.

     

    & ive only ever crashed the client by logging something really fast, if your client is crashing make the return of onLoop() 300+

     

    Link to comment
    Share on other sites

    8 minutes ago, camalCase said:

    the code in fish case looks okay, if its not logging "about to reel in some fish" it would have to be a problem in your get state method,

     before the if statements in getState(),  write a log() for each of those conditions and see if they're all true.

     

    & ive only ever crashed the client by logging something really fast, if your client is crashing make the return of onLoop() 300+

     

    I've added the log() to each condition in the getState() like you said without any result. Also when I start the script with a full inventory of fish. It does log 

    log("Inventory is Full. Dropping fish now!");
    

    But after dropping all the fish it crashes again. :(

    Link to comment
    Share on other sites

    log(Inventory.contains(Feather, FlyFishingRod))
    log(!Inventory.contains(RawSalmon, RawTrout))
    log(BarbarianVillageSpot.contains(getLocalPlayer())

    all return true and getState isnt returning FISH? idk how that could be possible.

     

    what does getState return if none of the if statements return true?

    Link to comment
    Share on other sites

    23 minutes ago, camalCase said:
    log(Inventory.contains(Feather, FlyFishingRod))
    log(!Inventory.contains(RawSalmon, RawTrout))
    log(BarbarianVillageSpot.contains(getLocalPlayer())

    all return true and getState isnt returning FISH? idk how that could be possible.

     

    what does getState return if none of the if statements return true?

    Ok, so when I am standing on the everlasting fire in next to Barbarian Village. It returns all 3 things true, then it does log

    case FISH:
        log("About to reel in some fish");
    

    And after this it crashes again. So yes, I was dumb that I didn't stand on the location in the first place. Sorry for wasting your time haha.

    But knowing that, there must be something wrong with this, right?

    NPC FishingSpot = NPCs.closest(f -> f != null && f.getName().contentEquals("Fishing spot") && BarbarianVillageSpot.contains(f));
    FishingSpot.interact("Lure");
    sleep(10000);
    

     

     

    Oh wait, after seeing this code above, could it be that the square I marked does not contain a fishing spot

    BarbarianVillageSpot.contains(f)

    I selected an area without any water.

    Edit: I tried changing the coördinates of the square, but it didn't work.

    Edited by UnusualPerson
    Link to comment
    Share on other sites

    Just now, UnusualPerson said:

    And after this it crashes again. So yes, I was dumb that I didn't stand on the location in the first place. Sorry for wasting your time haha.

    But knowing that, there must be something wrong with this, right?

     

    what do you mean when you say crashes? does the client close or does it say "Script threw an error, contact script maker" (something like that), if the latter click the message to open the console and post what it says

    Just now, UnusualPerson said:

    Oh wait, after seeing this code above, could it be that the square I marked does not contain a fishing spot

     

    yeah, you also arent null checking before fishing ie

    if (fishingSpot != null) {

    fishingSpot.interact();

    }

    you null check in the filter but i dont think that does anything

     

    Edited by camalCase
    grammar
    Link to comment
    Share on other sites

    9 minutes ago, camalCase said:

    what do you mean when you says crashes? does the client close or does it say "Script threw an error, contact script maker" (something like that), if the latter click the message to open the console and post what it says

    yeah, you also arent null checking before fishing ie

    if (fishingSpot != null) {

    fishingSpot.interact();

    }

    you null check in the filter but i dont think that does anything

     

    With crashing I mean getting an error in the console.

    After adding:

    if (FishingSpot != null){
        FishingSpot.interact("Lure");
        sleep(5000);
    }

    I am not getting any errors, but my charactar still won't fish, so i added:

    log(FishingSpot);
    

    To see if there is a fishing spot and it returned "null".

     

    Edit:

    It also runs through all code and even prints that my inventory is full when it isn't and this should only happen in the "drop" case.

    Edited by UnusualPerson
    Link to comment
    Share on other sites

    7 minutes ago, UnusualPerson said:

    With crashing I mean getting an error in the console.

     

    okay makes alot more sense now
    when you're calling NPCs.closest its returning null because theres no NPCs that match your filter, this is probably because the fishing spot isnt in your area could also be because of contentEquals, normally i use equalsIgnoreCase or contains

     

    7 minutes ago, UnusualPerson said:

    It also runs through all code and even prints that my inventory is full when it isn't and this should only happen in the "drop" case.

    do you have "break;" at the end of your fishing case?

     

     

     

    Edited by camalCase
    correction
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.