Jump to content

How to check if npc was interacting other player within last 10 seconds?


qverkk

Recommended Posts

How to check if npc was interacting other player within last 10 seconds?

 

        for(Player player : getPlayers().getAll()){

            List<NPC> guards = getNpcs().filter(npc ->
                    npc.getName().equals("Guard") && npc.getLevel() == 1337
                             && npc.isInteracting(player)
            );

            if(guards.size() > 0 && inventory.contains(food)){
                if(room6.contains(myPlayer()) || room6a.contains(myPlayer())) {
                    RS2Object door1 = getObjects().closest(true, obj -> obj.getName().equals("Door") && obj.hasAction("Open") && obj.getX() == dx1 && obj.getY() == dy1);
                    if (door1 == null) { // if doors r open doors open walk outside
                        localWalker.walk(centerX, centerY);
                    } else if (!room6SafeArea.contains(myPlayer())) { 
                        localWalker.walk(safeX, safeY);
                        break;
                    }
                }//if we're in safe area, sleep
                sleep(20000);
            }
        }
Link to comment
Share on other sites

Get the npc and check every loop whether it is interacting or not, if it has to be interacting with other players then also check that you are not interacting with this npc. If it was interacting in a previous loop iteration and now it is no longer interacting, you start timing 10 seconds (just save the time and check if 10 seconds have passed in further loop iterations) and then you got what you wanted.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...