Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Returning an array of Inventory Items?

Featured Replies

Hello, once again I come with a question but this time regarding the Inventory.

 

I was surfing the API when I wanted to find out if it was possible to return the id of an item in a specific slot OR return the entire array of items held in ones inventory.

 

Thanks for any help, I have found the Item[] getItems() and then getSlot(). If somone could help clarify the use for these and how one could use them for an array that would be great.

 

Thanks again OSBot community.

Hello, once again I come with a question but this time regarding the Inventory.

 

I was surfing the API when I wanted to find out if it was possible to return the id of an item in a specific slot OR return the entire array of items held in ones inventory.

 

Thanks for any help, I have found the Item[] getItems() and then getSlot(). If somone could help clarify the use for these and how one could use them for an array that would be great.

 

Thanks again OSBot community.

getItems(); returns an array of type Item.

 

what do you plan on doing?

 

 

Precise

  • Author

getItems(); returns an array of type Item.

 

what do you plan on doing?

 

 

Precise

 

I basically plan on grabbing all the ids from the inventory and loading it into an array in which if the person needs to stock up with that exact load out they started with, it will withdraw that same load out by going through the array.

 

The getItems() is an Items array, how would I turn that into an int.

I basically plan on grabbing all the ids from the inventory and loading it into an array in which if the person needs to stock up with that exact load out they started with, it will withdraw that same load out by going through the array.

 

The getItems() is an Items array, how would I turn that into an int.

 

may i ask, do you know the basics of java?

anyways:

int[] itemIds = new int[getInventory().getItems().length-1];

for (int i = 0; i < itemIds.length; i++) 
    itemIds[i] = getInventory().getItems()[i].getId();
  • Author

may i ask, do you know the basics of java?

 

Yes, I've been coding in Java for around 5 years. Started on old clients but they had methods that allowed you to select the slot and return that id which would be easier for creating the array of items.

 

the getItems() like I said are held by the Items[] array which are held by inventory.

 

Like I was my question is, the Items array. If I did         Item[] temp = inventory.getItems();

then returned the size of temp and put it into a loop, would it be spitting out integers or more?

 

may i ask, do you know the basics of java?

anyways:

int[] itemIds = new int[getInventory().getItems().length-1];

for (int i = 0; i < itemIds.length; i++) 
    itemIds[i] = getInventory().getItems()[i].getId();

 

Also thanks for that, still reviewing this api. A bit more lengthy then some I have seen but it's a lot more accurate.

So confusing on what you want..so I'll do my best.

 

Usage for grabbing the players inventory as an Item array:

inventory.getItems()

 

Since you want to store their initial setup, I'd do something like:

initial = inventory.getItems()
upon startup

 

To grab the amount of an item object (returned as an integer), simply do:

item.getAmount()
 

 

Put it all together, you should end up with something like this:

for (int i = 0; i < inventory.getItems().length; i++) {
Item current = inventory.getItems()[i]; //the current item in the respective slot
Item in = initial[i];  //the initial item in the respective slot
//probably want to skip iteration if the item is null but idk
if (in.getAmount() != current.getAmount()) { //if the initial amount is different to the current amount...
bank.withdraw(current.getId(), in.getAmount() - current.getAmount()); //withdraw the necessary amount
}
}

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.