Acerd Posted June 19, 2016 Share Posted June 19, 2016 (edited) This has never happened to me so I'm kind of confused why this is happening; basically it walks to an area and interacts with NPC and logs that npc isnt null, goes to bank and then goes back to the area , however this time it logs that the NPC is null.What am I doing wrong? code: NPC npc = getNpcs().closest("NPC"); // onloop if (!area.contains(myPlayer()) { getWalking().webWalk(area); } else { if (npc != null) { log("npc is not null"); npc.interact(); } else { log("npc is null"); } } Edited June 19, 2016 by Acerd Quote Link to comment Share on other sites More sharing options...
Mydog80 Posted June 19, 2016 Share Posted June 19, 2016 try elseif Quote Link to comment Share on other sites More sharing options...
Acerd Posted June 19, 2016 Author Share Posted June 19, 2016 (edited) try elseif ive tried dat too if u mean: if (!area.contains(myPlayer()) { getWalking().webWalk(area); } else if (npc != null) { log("npc not null"); } Edited June 19, 2016 by Acerd Quote Link to comment Share on other sites More sharing options...
Woody Posted June 19, 2016 Share Posted June 19, 2016 Get closest npc when you're inside the area Quote Link to comment Share on other sites More sharing options...
Acerd Posted June 19, 2016 Author Share Posted June 19, 2016 Get closest npc when you're inside the area i tried that too Quote Link to comment Share on other sites More sharing options...
Explv Posted June 19, 2016 Share Posted June 19, 2016 (edited) Can you show your actual code? Edited June 19, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
Mydog80 Posted June 20, 2016 Share Posted June 20, 2016 why not try NPC Goblin = npcs.closest("Goblin"); if (Goblin != null && !(Goblin.isUnderAttack())) //getMap().canReach(Goblin) { if (Goblin.isVisible()) { Goblin.interact(new String[]{"Attack"}); new ConditionalSleep(3000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating() || myPlayer().getInteracting() != null; } }.sleep(); } } else if (!Goblin.isVisible()) { this.camera.toEntity((Entity) Goblin); if (Goblin.exists() && !Goblin.isVisible()) { walking.walk(Goblin); while(myPlayer().isMoving()) { sleep(250); } } Quote Link to comment Share on other sites More sharing options...
Explv Posted June 20, 2016 Share Posted June 20, 2016 some unreadable code In the future please use the code tags to format your code when posting/commenting in the scripting help section. 1 Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted June 20, 2016 Share Posted June 20, 2016 You can only detect NPC's when they are actualy visible on the minimap. thats about 16 tiles from your player. Quote Link to comment Share on other sites More sharing options...