Jump to content

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


Recommended Posts

Posted

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);
            }
        }
Posted

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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