Likeyou343 0 Share Posted August 17, 2017 (edited) 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 Edited August 17, 2017 by Likeyou343 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 (edited) 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. Edited August 17, 2017 by DefCon Link to comment Share on other sites More sharing options...
Genius 43 Share Posted August 17, 2017 It was likely due to the RS update. Should work now. DefCon 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now