Jump to content

inventory.GetAmount("Coins") bugging occasionally


k9thebeast

Recommended Posts

Hey All :) Inb4 all the "Why is the bot down" posts.

 

My question has to do with the inventory.GetAmount("Coins") statement and why some times the below getState() method sometimes returns State.A

 

Usually inventory.GetAmount("Coins") returns the correct amount, however lately when the computer lags a little it returns 0. It happens occasionally on my windows vm, but on my Linux VPS as well (and more often) that I notice has more graphical lag than my windows (but it could just be the VNC connection). 

 

I dont want to put a "&& !=0" check for the .getAmount function because it is possible that the function could return 0 and this isnt great practice in general.

 

Does everyone use this method? Has anyone run into this error before? 

if(inventory.getAmount("Coins") < 8000){
    return State.A;
}else if(inventory.isFull() || myPlayer().isUnderAttack()){
    return State.B;
}else{
    return State.C;
}
Link to comment
Share on other sites

Hey All :) Inb4 all the "Why is the bot down" posts.

My question has to do with the inventory.GetAmount("Coins") statement and why some times the below getState() method sometimes returns State.A

Usually inventory.GetAmount("Coins") returns the correct amount, however lately when the computer lags a little it returns 0. It happens occasionally on my windows vm, but on my Linux VPS as well (and more often) that I notice has more graphical lag than my windows (but it could just be the VNC connection).

I dont want to put a "&& !=0" check for the .getAmount function because it is possible that the function could return 0 and this isnt great practice in general.

Does everyone use this method? Has anyone run into this error before?

if(inventory.getAmount("Coins") < 8000){    return State.A;}else if(inventory.isFull() || myPlayer().isUnderAttack()){    return State.B;}else{    return State.C;}
Where are you calling this method? Just to make sure you aren't doing something incorrect?

If you aren't then you should file a bug report

Edited by Explv
Link to comment
Share on other sites

Where are you calling this method? Just to make sure you aren't doing something incorrect?

If you aren't then you should file a bug report

 

I'm calling this method so that when I dont have enough money to buy from the shop any more it trades mule. Yea I think bug report may need to happen. Just wanted to get some input first. Thanks for the reply!

Link to comment
Share on other sites

Ah sorry. Here is my loop()

@[member='Override']
public int onLoop() throws InterruptedException {
    switch (getState()) {
    case A:
        log("State A");
        break;
    case B:
        log("State B");
        break;
    case C:
        log("State C");
        break;
    }

    return random(200,500);
} 
Edited by k9thebeast
Link to comment
Share on other sites

I assume you are hopping a lot because you mentioned store buying.

The inventory returns null or empty sometimes as a result of the loading screen.

 

I recommend adding 

 

if (getClient().getLoginState() == LoginState.LOADING || getClient().getLoginState() == LoginState.LOADING_MAP) {
return 300;
}

To your loop :)

Link to comment
Share on other sites

I assume you are hopping a lot because you mentioned store buying.

The inventory returns null or empty sometimes as a result of the loading screen.

 

I recommend adding 

 

if (getClient().getLoginState() == LoginState.LOADING || getClient().getLoginState() == LoginState.LOADING_MAP) {
return 300;
}

To your loop smile.png

Thank you sir I'll give it a go!

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