Jump to content

mlrkey

Members
  • Posts

    18
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by mlrkey

  1. Player p = getPlayers().closest(playerName);

     

    // ..

     

    p.interact("Attack");

     

    make sure to add the necessary checks, I'm only showing the core process. It's the same as any other <code>Entity</code>

     

    Any way to get the closest player without looking at name?

  2. 	public boolean dropOnlyThis(String[] blackList) throws IllegalArgumentException, InterruptedException {
    		if (getInventory().contains(blackList)) {
    			List<Item> list = getInventory().filter(new ContainsNameFilter<Item>(blackList));
    			for (Item item: list) {
    				if (item != null) {
    					item.interact("drop");
    					sleep(gRandom(400,100));
    				}
    			}
    		}
    		return !getInventory().contains(blackList);
    	}
    

    tell me if this helps

     

     

    I should have been more specific. I have 15 of a certain item in my inv and I want to only drop 5 of that item.

  3.  

    Going with the second method, here is a simplistic easy to follow way (completely untested and just for demonstration, but it should work):

        public int getAmountOf(String groundItemName){
            int numberOfItems = 0;
            java.util.List<GroundItem> allGroundItems = script.getGroundItems().getAll();
            if(allGroundItems != null && allGroundItems.size() > 0){
                for(GroundItem groundItem : allGroundItems){
                    if(groundItem != null && groundItem.getName() != null && groundItem.getName().equals(groundItemName)){
                        numberOfItems++;
                    }
                }
            }
            return numberOfItems;
        }
    

     

    Thanks a lot :) Will try soon

×
×
  • Create New...