IHB Posted May 2, 2016 Share Posted May 2, 2016 (edited) Whenever I run this script on a low-end pc instead of my main one if I switch bot tabs it always ends up returning the state OUT_OF_FOOD straight away, even when the conditions aren't true? It also happens when the bot first logs in, it immediately returns OUT_OF FOOD and I can't figure out why. On my main pc it works properly but it's just on this other pc with lower specs This is where my script grabs it's state: public State GetState() { if (!players.inventory.contains(FOOD) && AREA.contains(myPlayer())) { return State.WALK; } if (!players.inventory.contains(FOOD)&& COMBAT_AREA.contains(myPlayer())) { return State.OUT_OF_FOOD; } if (myPlayer().isUnderAttack()) { return State.IN_COMBAT; } if (!myPlayer().isUnderAttack() && COMBAT_AREA.contains(myPlayer())){ return State.ATTACKING; } else return State.ATTACKING; } For eg: inventory contains food and its in combatarea but still returns it? As soon as i stop the script and start it again it returns the correct state which is attacking Edited May 2, 2016 by IHB Quote Link to comment Share on other sites More sharing options...
Token Posted May 2, 2016 Share Posted May 2, 2016 Remove players. from players.inventory as the inventory field is inherited in your class that extends Script, that would be first step. Try posting more code as I don't think that's the only issue in there. Quote Link to comment Share on other sites More sharing options...
Acerd Posted May 2, 2016 Share Posted May 2, 2016 whats "players"? try using getInventory().contains(FOOD) Quote Link to comment Share on other sites More sharing options...
IHB Posted May 2, 2016 Author Share Posted May 2, 2016 (edited) Remove players. from players.inventory as the inventory field is inherited in your class that extends Script, that would be first step. Try posting more code as I don't think that's the only issue in there. whats "players"? try using getInventory().contains(FOOD) As the two said above I don't see anything wrong other then what is stated above. Thanks for the replies I'll try removing the players. from it, it was auto-generated before so I just used it It works on my normal pc but on the login on a bad pc it returns the wrong state right away (but after that it's fine) Edit: Nope still having the same issue if I start the script already logged in it is fine it's just when it auto-logs in for me? Edited May 2, 2016 by IHB Quote Link to comment Share on other sites More sharing options...
Strange_Fk Posted May 2, 2016 Share Posted May 2, 2016 Instead of public State GetState() { if (!players.inventory.contains(FOOD) && AREA.contains(myPlayer())) { return State.WALK; } if (!players.inventory.contains(FOOD)&& COMBAT_AREA.contains(myPlayer())) { return State.OUT_OF_FOOD; } if (myPlayer().isUnderAttack()) { return State.IN_COMBAT; } if (!myPlayer().isUnderAttack() && COMBAT_AREA.contains(myPlayer())){ return State.ATTACKING; } else return State.ATTACKING; } try swapping the if() statements for attacking and out of food like this public State GetState() { if (!players.inventory.contains(FOOD) && AREA.contains(myPlayer())) { return State.WALK; } if (!myPlayer().isUnderAttack() && COMBAT_AREA.contains(myPlayer())){ return State.ATTACKING; } if (!players.inventory.contains(FOOD) && COMBAT_AREA.contains(myPlayer())) { return State.OUT_OF_FOOD; } if (myPlayer().isUnderAttack()) { return State.IN_COMBAT; } } It might help temporarily solve the issue, but the problem could be somewhere else in your script that leads to this issue Quote Link to comment Share on other sites More sharing options...
IHB Posted May 2, 2016 Author Share Posted May 2, 2016 Instead of public State GetState() { if (!players.inventory.contains(FOOD) && AREA.contains(myPlayer())) { return State.WALK; } if (!players.inventory.contains(FOOD)&& COMBAT_AREA.contains(myPlayer())) { return State.OUT_OF_FOOD; } if (myPlayer().isUnderAttack()) { return State.IN_COMBAT; } if (!myPlayer().isUnderAttack() && COMBAT_AREA.contains(myPlayer())){ return State.ATTACKING; } else return State.ATTACKING; } try swapping the if() statements for attacking and out of food like this public State GetState() { if (!players.inventory.contains(FOOD) && AREA.contains(myPlayer())) { return State.WALK; } if (!myPlayer().isUnderAttack() && COMBAT_AREA.contains(myPlayer())){ return State.ATTACKING; } if (!players.inventory.contains(FOOD) && COMBAT_AREA.contains(myPlayer())) { return State.OUT_OF_FOOD; } if (myPlayer().isUnderAttack()) { return State.IN_COMBAT; } } It might help temporarily solve the issue, but the problem could be somewhere else in your script that leads to this issue Thanks for the reply but the logic in that would be flawed as it would return ATTACKING before OUT_OF_FOOD in the case that it was actually out of food, meaning it would never bank and where else do you think it could be going wrong? Quote Link to comment Share on other sites More sharing options...
Shudsy Posted May 2, 2016 Share Posted May 2, 2016 Maybe you forgot to add "break;" in one of your states? Quote Link to comment Share on other sites More sharing options...
IHB Posted May 2, 2016 Author Share Posted May 2, 2016 Maybe you forgot to add "break;" in one of your states? Nope all my states have break in them I can't figure it out Quote Link to comment Share on other sites More sharing options...
Woody Posted May 2, 2016 Share Posted May 2, 2016 Thanks for the reply but the logic in that would be flawed as it would return ATTACKING before OUT_OF_FOOD in the case that it was actually out of food, meaning it would never bank and where else do you think it could be going wrong? Your logic is flawed. You should have more/better conditions. Quote Link to comment Share on other sites More sharing options...
IHB Posted May 2, 2016 Author Share Posted May 2, 2016 Your logic is flawed. You should have more/better conditions. Sorry if I upset you, my logic works fine for 12 hours straight IF I start the script already logged in, however if it does an auto-login it returns the outoffood state straight away and banks, after that it is fine though. I'm just trying to work out why it thinks that those conditions are true in the first getState when it logs in? Quote Link to comment Share on other sites More sharing options...
Woody Posted May 2, 2016 Share Posted May 2, 2016 (edited) I'm just trying to work out why it thinks that those conditions are true in the first getState when it logs in? Because your logic is flawed. Trust me, you will never make me upset. EDIT: Why do you even have an OUT_OF_FOOD state? What purpose does it have? Just do: if out of food -> go to bank to retrieve food (return state.WALK) Edited May 2, 2016 by Woody Quote Link to comment Share on other sites More sharing options...
IHB Posted May 2, 2016 Author Share Posted May 2, 2016 (edited) Because your logic is flawed. Trust me, you will never make me upset. EDIT: Why do you even have an OUT_OF_FOOD state? What purpose does it have? Just do: if out of food -> go to bank to retrieve food (return state.WALK) That's what the state is for, banking case OUT_OF_FOOD: log("State: OUT_OF_FOOD"); CURRENT = "OUT OF FOOD"; Banking(); break; Edited May 2, 2016 by IHB Quote Link to comment Share on other sites More sharing options...
Strange_Fk Posted May 2, 2016 Share Posted May 2, 2016 Sorry if I upset you, my logic works fine for 12 hours straight IF I start the script already logged in, however if it does an auto-login it returns the outoffood state straight away and banks, after that it is fine though. I'm just trying to work out why it thinks that those conditions are true in the first getState when it logs in? Lmfao its because when u run script when not logged in it wont be able to retrieve your inventory probably until fully logged in. Try adding a boolean to the out of food portion that states that the account is fully logged in as well 1 Quote Link to comment Share on other sites More sharing options...
Woody Posted May 2, 2016 Share Posted May 2, 2016 (edited) That's what the state is for, banking case OUT_OF_FOOD: log("State: OUT_OF_FOOD"); CURRENT = "OUT OF FOOD"; Banking(); break; Ugh.. Your conditions and naming your states are so flawed. If you want help, post your code and perhaps we can help you with your problem. Edit: try something like this if got food if in combat area if not under attack return state.FIGHT else return state.WAIT else return state.WALK_TO_COMBAT_AREA else if in bank area return state.BANK else return state.WALK_TO_BANK Edited May 2, 2016 by Woody Quote Link to comment Share on other sites More sharing options...
IHB Posted May 2, 2016 Author Share Posted May 2, 2016 Lmfao its because when u run script when not logged in it wont be able to retrieve your inventory probably until fully logged in. Try adding a boolean to the out of food portion that states that the account is fully logged in as well Thank you v much fixed 1 Quote Link to comment Share on other sites More sharing options...