Jump to content

How to ensure player only chops in specified area?


Recommended Posts

Posted (edited)
private RS2Object tree;
private Area someArea = new Area(x1, y1, x2, y2;


public boolean chopTree(){
   List<RS2Object> trees = getObjects().getAll().stream().filter(ob -> ob != null && ob.getName().equalsIgnoreCase("Tree") && canChop(ob)).collect(Collectors.toList());

   if(!myPlayer().isAnimating() && trees.size() > 0){
      RS2Object tree = trees.get(Script.random(trees.size()));
      if(tree.interact("Chop down"){
         //sleep or something
         return true;
      }
   }

   return false;
} 

public boolean canChop(RS2Object tree){
     return someArea.contains(tree);
}

Alternative to @FrostBugs happy.png All code from my head so just double check.

Edited by Extreme Scripts

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...