Jump to content

Bot crashes when not in the area of npc


Recommended Posts

Posted

I have a simple fishing bot, if you don't have the items needed it goes to get the items from your bank then goes to fish. The only problem is I use 

npcs.closest("Rod fishing spot").interact("lure");

to find the fishing spot. When I'm at the bank it just crashes after getting the items/being started(if it has the items.) If I start the bot in view of the fishing spots with the items it works perfectly. Help is much appreciated

Posted
Area FISHING_AREA = new Area(x, x, x, x);
if (FISHING_AREA.contains(myPlayer()) {
  NPC fishingSpot = npcs.closest("Rod fishing spot");
  if (fishingSpot != null)  {
    fishingSpot.interact("lure");
    ConditionalSleeepHere until interacting
  }
}
    

will only search for the fishing spot if you're in the area you need to be. Also checks if it found the spot before interacting.

Basically just make sure that you interact only when you're sure that you have something to interact with

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...