Jammer Posted November 25, 2017 Share Posted November 25, 2017 I'm making a task based script which includes buying gear from grand exchange. I have one task for banking and one for buying. The buytask should execute when the required arrmor is not in my Inventory, bank or equiped. When the bank is open it works fine and it goes to GE. However when the bank isn't open and I already have the required items in the bank it still thinks it should buy things. I assume this is due to it not knowing what's in the bank when the bank isn't open. It basically boils down to this: Is it possible to store the items in the bank in an arraylist and update it every time i withdraw or deposit something or are there better ways of implementing buying? Quote Link to comment Share on other sites More sharing options...
Explv Posted November 25, 2017 Share Posted November 25, 2017 4 minutes ago, Jammer said: I'm making a task based script which includes buying gear from grand exchange. I have one task for banking and one for buying. The buytask should execute when the required arrmor is not in my Inventory, bank or equiped. When the bank is open it works fine and it goes to GE. However when the bank isn't open and I already have the required items in the bank it still thinks it should buy things. I assume this is due to it not knowing what's in the bank when the bank isn't open. It basically boils down to this: Is it possible to store the items in the bank in an arraylist and update it every time i withdraw or deposit something or are there better ways of implementing buying? Why don't you just check if the player already has the items in their inventory / equipment? If they don't then check the bank If they still don't then go to GE. Sounds like the structure of your code is borked ("Task" pattern sucks) 2 Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted November 25, 2017 Share Posted November 25, 2017 Bank Caches Quote Link to comment Share on other sites More sharing options...
Jammer Posted November 25, 2017 Author Share Posted November 25, 2017 2 minutes ago, Explv said: Why don't you just check if the player already has the items in their inventory / equipment? If they don't then check the bank If they still don't then go to GE. Sounds like the structure of your code is borked ("Task" pattern sucks) Wow, I can't believe I didn't think of that. Yeah, task based was actually messier than I anticipated but it might just have to do with my lack of skills. After I finish this script I'm gonna have a look at your tutorial island script and try to use that kind of framework. Quote Link to comment Share on other sites More sharing options...
dreameo Posted November 25, 2017 Share Posted November 25, 2017 24 minutes ago, Jammer said: It basically boils down to this: Is it possible to store the items in the bank in an arraylist and update it every time i withdraw or deposit something or are there better ways of implementing buying 12 minutes ago, HeyImJamie said: Bank Caches Yea pretty much anytime you close the bank, update arraylist of items in the bank before you close (or finished with bank). That way you don't need to go and check every time. Make sure the items are updated before you check them tho, so like depending on where you start your script, the bank cache might not be initialized. 1 Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted November 25, 2017 Share Posted November 25, 2017 (edited) I'd personally use a HashMap or something similar rather than an arraylist so you can store the string/item and the amount rather than just one or the other. I'd put an initialisation check in regards to size and save it if it's not been saved, eg if size is 0 - load the cache, else set the cache everytime you open bank or w/e Edited November 25, 2017 by HeyImJamie 1 Quote Link to comment Share on other sites More sharing options...
dreameo Posted November 25, 2017 Share Posted November 25, 2017 11 minutes ago, HeyImJamie said: I'd personally use a HashMap or something similar rather than an arraylist so you can store the string/item and the amount rather than just one or the other. I'd put an initialisation check in regards to size and save it if it's not been saved, eg if size is 0 - load the cache, else set the cache everytime you open bank or w/e Well, he's looking for equipment. So in this case, the list contains it or not, the quantity is implied. Quote Link to comment Share on other sites More sharing options...
Explv Posted November 25, 2017 Share Posted November 25, 2017 21 minutes ago, dreameo said: Yea pretty much anytime you close the bank, update arraylist of items in the bank before you close (or finished with bank). That way you don't need to go and check every time. Make sure the items are updated before you check them tho, so like depending on where you start your script, the bank cache might not be initialized. 16 minutes ago, HeyImJamie said: I'd personally use a HashMap or something similar rather than an arraylist so you can store the string/item and the amount rather than just one or the other. I'd put an initialisation check in regards to size and save it if it's not been saved, eg if size is 0 - load the cache, else set the cache everytime you open bank or w/e Except he doesn't need to cache anything.. The structure of his code is the problem. Quote Link to comment Share on other sites More sharing options...
progamerz Posted November 25, 2017 Share Posted November 25, 2017 You can try using booleans if you are not looking to make the structure better. Quote Link to comment Share on other sites More sharing options...
dreameo Posted November 25, 2017 Share Posted November 25, 2017 2 minutes ago, Explv said: Except he doesn't need to cache anything.. The structure of his code is the problem. Your suggesting to just check in this order: equipment --> bank --> go buy from ge Caching it would just eliminate the step of having to check the bank since you'd already know what you don't have. Quote Link to comment Share on other sites More sharing options...
Explv Posted November 25, 2017 Share Posted November 25, 2017 Just now, dreameo said: Your suggesting to just check in this order: equipment --> bank --> go buy from ge Caching it would just eliminate the step of having to check the bank since you'd already know what you don't have. That depends on whether he plans on losing his equipment during the script. If he only needs to check once, why cache? Quote Link to comment Share on other sites More sharing options...
dreameo Posted November 25, 2017 Share Posted November 25, 2017 2 minutes ago, Explv said: That depends on whether he plans on losing his equipment during the script. If he only needs to check once, why cache? So he finishes one task, goes to a second but needs certain gear. If he cached his bank, he will know whether to buy or go to bank. Quote Link to comment Share on other sites More sharing options...
Explv Posted November 25, 2017 Share Posted November 25, 2017 9 minutes ago, dreameo said: So he finishes one task, goes to a second but needs certain gear. If he cached his bank, he will know whether to buy or go to bank. Really depends on what script he is making. Quote Link to comment Share on other sites More sharing options...
Jammer Posted November 25, 2017 Author Share Posted November 25, 2017 (edited) It's gonna start leveling combat from scratch so I'm gonna have to use GE multiple times. I'll try what explv suggested and if the bank task and the buy task conflict with each other I'll try the cache thing. Edit: thanks for the help btw. Edited November 25, 2017 by Jammer Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted November 25, 2017 Share Posted November 25, 2017 1 hour ago, dreameo said: Well, he's looking for equipment. So in this case, the list contains it or not, the quantity is implied. My fault, didn't fully read. Quote Link to comment Share on other sites More sharing options...