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
  • Try asking for help in the chatbox
  • dropAll(Filter)


    xVril
     Share

    Recommended Posts

    Hi, 

    I have a scenario that requires the player has at least 3 empty inventory spaces. There are a number of items that the inventory will contain that I do not need so I created a custom filter for this:

    public static final Filter<Item> ITEMS_TO_DROP = item -> item.getID() == 1 || item.getID() == 2
    			|| item.getID() == 3 || item.getID() == 4 || item.getID() == 5 || item.getID() == 6;

    I use the following check 

    		if (s.getInventory().emptySlotCount() < 3) {
    			s.getInventory().dropAll(Filters.ITEMS_TO_DROP);
    		}

    This works fine and will drop these items when the inventory is full, the issue occurs when I have an empty slot.

    Any ideas or will I just have to check each inventory slot individually to see if it is empty?

    Link to comment
    Share on other sites

    Public String[] junkItems = {};

     

    If (empty slots < threshold) {

    For (Item i: inventoryitems) {

    For (string s : junkItems) {

    If (I! = null and I.getName().contains(s)) {

    Drop I

    }

    }

    }

     

    Excuse the formatting/Pseudo code, written in reply box on phone.

     

    The above will iterate over inventory items, if an items name matches one of those present in the string array then drop it.

    Edited by Pseudo
    Link to comment
    Share on other sites

    5 hours ago, Pseudo said:

    Public String[] junkItems = {};

     

    If (empty slots < threshold) {

    For (Item i: inventoryitems) {

    For (string s : junkItems) {

    If (I! = null and I.getName().contains(s)) {

    Drop I

    }

    }

    }

     

    Excuse the formatting/Pseudo code, written in reply box on phone.

     

    The above will iterate over inventory items, if an items name matches one of those present in the string array then drop it.

    Thanks for your help. Managed to get a solution based on your response.

    			for(Item i : s.getInventory().all()) {
    				if(Filters.ITEMS_TO_DROP.match(i)) {
    					s.getInventory().drop(i.getID());
    				}
    			}

     

     

    Link to comment
    Share on other sites

    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
     Share

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