Jump to content

Bot crashes when not in the area of npc


bigd123

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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