Likeyou343 0 Share Posted August 17, 2017 I have this kind of code here and for some reason the npc interaction doesn't work. NPC npc = getNpcs().closest(new String[]{"Name1", "Name2"}); if (npc != null) { // npc.toString() outputs Name1: [id] // code reaches up till here npc.interact("Trade"); // code does not reach here } I tried making getNpcs().closest("Name1") only but it still does not work. Code doesn't go further if I try to do npc.isOnScreen() as well Edit: randomly started working. Did not change anything Link to comment Share on other sites More sharing options...
distraction 61 Share Posted August 17, 2017 I have this kind of code here and for some reason the npc interaction doesn't work. NPC npc = getNpcs().closest(new String[]{"Name1", "Name2"}); if (npc != null) { // npc.toString() outputs Name1: [id] // code reaches up till here npc.interact("Trade"); // code does not reach here } I tried making getNpcs().closest("Name1") only but it still does not work. Code doesn't go further if I try to do npc.isOnScreen() as well Do any npcs actually have a "trade" option? It sounds like you may be trying to trade with a player. If that is the case, you should use `getPlayers()` and not `getNpcs()`. Link to comment Share on other sites More sharing options...
Likeyou343 0 Author Share Posted August 17, 2017 Do any npcs actually have a "trade" option? It sounds like you may be trying to trade with a player. If that is the case, you should use `getPlayers()` and not `getNpcs()`. It is npcs with trade option Link to comment Share on other sites More sharing options...
DefCon 121 Share Posted August 17, 2017 Do any npcs actually have a "trade" option? It sounds like you may be trying to trade with a player. If that is the case, you should use `getPlayers()` and not `getNpcs()`. According to his code commentation, he has successfully found the Entity that he's looking for. So the getNpcs() method looks all good. @OP: Did you get an error message in the client? If not, run the client in debug mode so we can see any errors through the cmd prompt. Link to comment Share on other sites More sharing options...
Genius 49 Share Posted August 17, 2017 It was likely due to the RS update. Should work now. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.