Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • npc.interact doesn't work


    Likeyou343

    Recommended Posts

    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

    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

    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

    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

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.