bigd123 Posted February 9, 2019 Share Posted February 9, 2019 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 Quote Link to comment Share on other sites More sharing options...
sellout_89 Posted February 9, 2019 Share Posted February 9, 2019 After you are finished at the bank you should have a check if your in the fishing area (create an area variable) if not walk there else find the closest fishing spot and interact Quote Link to comment Share on other sites More sharing options...
bigd123 Posted February 9, 2019 Author Share Posted February 9, 2019 Well, I was hoping to have it find the closest place that has a fishing spot, not have one preset. Quote Link to comment Share on other sites More sharing options...
NoxMerc Posted February 9, 2019 Share Posted February 9, 2019 RS only loads an area around you of a radius about 50 tiles or so. You can't just load all of the NPCs across the entire game and hope it finds the closest fishing spot to you. Quote Link to comment Share on other sites More sharing options...
bigd123 Posted February 9, 2019 Author Share Posted February 9, 2019 Is there any solution? or do I just have it go to specific areas? Quote Link to comment Share on other sites More sharing options...
Hel Posted February 9, 2019 Share Posted February 9, 2019 57 minutes ago, bigd123 said: Is there any solution? or do I just have it go to specific areas? nullcheck it first. You're getting a crash because you're trying to interact with something that doesn't exist. Quote Link to comment Share on other sites More sharing options...
Butters Posted February 9, 2019 Share Posted February 9, 2019 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 Quote Link to comment Share on other sites More sharing options...
RedStrikers Posted February 9, 2019 Share Posted February 9, 2019 If you're not in the area, there are no fishing spots, so your "npcs" array has 0 length. There should be a function to check array length, and if its 0, don't operate on it. your code should be something like this: if npcs.length > 0 { npcs.closest.interact } else { go to fishing spot } Quote Link to comment Share on other sites More sharing options...