Acerd Posted June 19, 2016 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
Acerd Posted June 19, 2016 Author 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
Acerd Posted June 19, 2016 Author Posted June 19, 2016 Get closest npc when you're inside the area i tried that too
Explv Posted June 19, 2016 Posted June 19, 2016 (edited) Can you show your actual code? Edited June 19, 2016 by Explv 1
Mydog80 Posted June 20, 2016 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); } }
Explv Posted June 20, 2016 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
Khaleesi Posted June 20, 2016 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.