Jump to content

Not Dropping All


debug

Recommended Posts

I'm not sure why this isn't working, but when it gets to the Drop method it will start from the top and begin dropping, but it will leave the bottom logs, sometimes 1, sometimes 2 and it will keep building up.

if (sI.inventory.isFull() && !sI.myPlayer().isAnimating()) {
            for (Item i : sI.getInventory().getItems()) {
                if (i != null && i.getName().equals("Logs")) {
                	sI.inventory.dropAll(i.getName());
                    sleep(random(300, 1200));
                }
            }
        }
Link to comment
Share on other sites

 

I'm not sure why this isn't working, but when it gets to the Drop method it will start from the top and begin dropping, but it will leave the bottom logs, sometimes 1, sometimes 2 and it will keep building up.

if (sI.inventory.isFull() && !sI.myPlayer().isAnimating()) {
            for (Item i : sI.getInventory().getItems()) {
                if (i != null && i.getName().equals("Logs")) {
                	sI.inventory.dropAll(i.getName());
                    sleep(random(300, 1200));
                }
            }
        }

 

Well your code doesn't make much sense... Why would you call dropAll, a function which DROPS ALL on every single Log in your inventory?

 

It should just be:

if (sI.getInventory().isFull()) {
  sI.getInventory().dropAll("Logs");
}
Edited by Explv
Link to comment
Share on other sites

 

Well your code doesn't make much sense... Why would you call dropAll, a function which DROPS ALL on every single Log in your inventory?

 

It should just be:

if (sI.getInventory().isFull()) {
  sI.getInventory().dropAll("Logs");
}

What I was wondering aswell. On another note though, I tried it and it works for me.

 

Your method would make somewhat sense if you were making an api, seeing as you didnt pass a variable im assuming thats not the case, i'd use the snippet LoudPacks gave.

 

If you are using it to make a universal method, try this.

void dropAll(String itemName) {
		if(!myPlayer().isAnimating()) {
			for(Item i : getInventory().getItems()) {
				if(i.getName() == itemName) i.interact("Drop"); //Would typically be your own drop method here
			}
		}
	}
Edited by Prozen
Link to comment
Share on other sites

What I was wondering aswell. On another note though, I tried it and it works for me.

 

Your method would make somewhat sense if you were making an api, seeing as you didnt pass a variable im assuming thats not the case, i'd use the snippet LoudPacks gave.

 

If you are using it to make a universal method, try this.

void dropAll(String itemName) {
		if(!myPlayer().isAnimating()) {
			for(Item i : getInventory().getItems()) {
				if(i.getName() == itemName) i.interact("Drop"); //Would typically be your own drop method here
			}
		}
	}

Why would check within the method if player is animating and only drop if it isn't?

Doesn't really make sense to me.

Link to comment
Share on other sites

 

What I was wondering aswell. On another note though, I tried it and it works for me.

 

Your method would make somewhat sense if you were making an api, seeing as you didnt pass a variable im assuming thats not the case, i'd use the snippet LoudPacks gave.

 

If you are using it to make a universal method, try this.

void dropAll(String itemName) {
		if(!myPlayer().isAnimating()) {
			for(Item i : getInventory().getItems()) {
				if(i.getName() == itemName) i.interact("Drop"); //Would typically be your own drop method here
			}
		}
	}

 

1. You should use .equals() when comparing Strings. == Compares references not the values.

 

2. You should just use:

getInventory().dropAll(itemName);

3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items

 

lol

Edited by Explv
Link to comment
Share on other sites

1. You should use .equals() when comparing Strings. == Compares references not the values.

 

2. You should just use:

getInventory().dropAll(itemName);

3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items

 

lol

i think he wants to put random sleep time between ech item thats why he is not using that

Link to comment
Share on other sites

1. You should use .equals() when comparing Strings. == Compares references not the values.

 

2. You should just use:

getInventory().dropAll(itemName);

3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items

 

lol

I said in your own api, if you had your own drop and drop all method (not using osbot's drop method). as for checking if the player is animating yeah true that shouldnt be in the method since you should do the checks  before you call the dropAll method.

Link to comment
Share on other sites

I managed to fix it so it drops all of the inventory. I was trying to add a random sleep between each drop so it doesn't seem to bot like and fast.

 

If you want to add sleeps then you can do something like:

private void dropAll(final String name) throws InterruptedException {
    for(final Item item : getInventory().getItems()){
        if(item.getName().equals(name) && item.interact("drop")){
            sleep(random(200, 300));
        }
    }
}

But I am pretty sure that getInventory().dropAll(itemName) already does sleep a random amount from 25ms to 75ms in between drops. 

 

Edited by Explv
Link to comment
Share on other sites

If you want to add sleeps then you can do something like:

private void dropAll(final String name) throws InterruptedException {    for(final Item item : getInventory().getItems()){        if(item.getName().equals(name) && item.interact("drop")){            sleep(random(200, 300));        }    }}
But I am pretty sure that getInventory().dropAll(itemName) already does sleep a random amount from 25ms to 75ms in between drops.

Thanks, I'll try that. The reason is that I think the dropping is far to fast, and I can't drop items that fast so I was trying to make it delay around a second I will try your method and change the sleep and see if it works.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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