Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Am I doing something wrong? (Potential bug?)

Joined
Mar 21, 2014
Messages
36
So in my fisher i have this code once the inventory is full, I know it reaches this point as I am debugging every step and the debug logs show it to be in this phase...

7Kpyr.png


It does Drop only ONE fish out of the 26 in inventory...
Theoretically either i'm just completely stupid or it should work?
 
Discretion is advised
Joined
Jan 2, 2014
Messages
306
I think thats because you stored the fish you want to drop.. lets say that your dropAll variable gets a fish on slot 20, if you drop it, that item will be null so you cant drop it anymore, inside your while loop, you should loop through all items in your inventory and interact with any item with the "raw" string. Try it :p
 
Joined
Mar 9, 2014
Messages
40
What viewer is saying is correct. The SpriteItem is being declared and assigned once as a single RandomItem so try putting that underneath your while loop so the dropAll will be assigned every time to another fish through each loop
 
Joined
Mar 21, 2014
Messages
36
I'm almost positive that's it's an issue with your code if it's only dropping 5.

100% I am just trying to get direction as to where in my code it's happening, i knew it wasnt client related with 2nd bug :p
 
First Bot Author
Joined
Aug 7, 2013
Messages
262
dropAll is null, this frequently happens between gameticks, while a new region is loaded or the user is having minor connectivity issues.
As for the actual programming, containsAnyOf uses getItem and getRandomItem uses getItem: you're calling it twice, while that is not needed!

Code:
    private void dropInventory() {
        SpriteItem item = null;
        //Iterate a maximum of 28 times, in case we are somehow unable to actually drop items at all
        for (int i = 0; i < 28 && (item = Inventory.getRandomItem("Raw trout", "Raw salmon")) != null; i++) {
            if (item.interact("Drop")) {
                //Sucessfully dropped, might want to sleep a little bit or not
            }
        }
    }
 
Discretion is advised
Joined
Jan 2, 2014
Messages
306
Try this:
Code:
   public void drop(String... itemNames) {
        while(Inventory.containsAnyOf(itemNames)) {
            for (final SpriteItem item : Inventory.getItems()) {
                for (String name : itemNames) {
                    if(item != null && item.getDefinition().getName().toLowerCase().contains(name.toLowerCase())) {
                        if (item.interact("Drop")) {
                            Execution.delay(210,280);
                        }
                    }
                }
            }
        }
    }
 
Top