Jump to content

Items in bank


Recommended Posts

Posted

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?

 

 

 

Posted
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)

  • Like 2
Posted
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.

Posted
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 :boge: 

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.  

  • Like 1
Posted (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 by HeyImJamie
  • Like 1
Posted
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. 

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

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

Posted
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?

Posted (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 by Jammer

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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