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.

Checking for item in equipment slot

Featured Replies

I'm trying to see if my player has a ring of dueling in his equipment slot, but I am getting a NullPointerException.

Here is what I have so far, and it is not working.

if(!equipment.getItemInSlot(9).getName().startsWith("Ring of dueling")) {
				bank.withdraw(2552, 1); //withdraws ring of dueling(8)
			} else
					log("Already have a Ring of dueling.");

Does this work (if done correctly) if my bot currently has the bank open? Or do I have to tell it to open the eqiupment tab first, and then check if it has a ring or not?

 

Also, another thing I am having trouble with is using an inventory item on an object. Ex: Using a key on a door. How would I go about doing that?

 

Thanks for any help, in advance.

Edited by Aviri

Try,

if(equipment.isWearingItem(EquipmentSlot.RING, "dueling"))
{

}

Because if they don't have anything equipped then Item would be null and then you'd be trying to call the .getName() method on a null object, hints the null pointer.

Edited by Zero

I'm trying to see if my player has a ring of dueling in his equipment slot, but I am getting a NullPointerException.

Here is what I have so far, and it is not working.

Thanks for any help, in advance.

if(!equipment.getItemInSlot(9).getName().startsWith("Ring of dueling")) {
				bank.withdraw(2552, 1); //withdraws ring of dueling(8)
			} else
					log("Already have a Ring of dueling.");

Also, last thing, does this work (if done correctly) if my bot currently has the bank open? Or do I have to tell it to open the eqiupment tab first, and then check if it has a ring or not?

you are getting a npe when your checking the name of the item in slot 9. But you never did a null check on your item.

equipment.getItemInSlot(9) != null
//check name

when you first start a fresh client the bot has to check your equipment tab once. Ince that is done it can remember what tems you have on and dont need to close the bank.

Edited by Joseph

  • Author

Try,

if(equipment.isWearingItem(EquipmentSlot.RING, "dueling"))
{

}

Because if they don't have anything equipped then Item would be null and then you'd be trying to call the .getName() method on a null object, hints the null pointer.

 

Nope, getting a NullPointerException again. Note, this is with a ring of dueling equipted and without it equipted.

[ERROR][Bot #1][10/03 05:05:07 PM]: Error in script executor!
java.lang.NullPointerException
	at org.osbot.rs07.api.Equipment.getItems(yi:195)
	at org.osbot.rs07.api.util.ItemContainer.filter(ji:112)
	at org.osbot.rs07.api.Equipment.isWearingItem(yi:137)
	at org.osbot.rs07.api.Equipment.isWearingItem(yi:130)
	at main.onLoop(main.java:82)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(ck:136)
	at java.lang.Thread.run(Unknown Source)

Also, I edited the bottom of my original post with another question, let me know if you can help.

Thank you! :)

you are getting a npe when your checking the name of the item in slot 9. But you never did a null check on your item.

equipment.getItemInSlot(9) != null
//check name

when you first start a fresh client the bot has to check your equipment tab once. Ince that is done it can remember what tems you have on and dont need to close the bank.

 

Does the bot do this check automatically, or do I have to do that check within my script?

Thank you for your help!

Also, another thing I am having trouble with is using an inventory item on an object. Ex: Using a key on a door. How would I go about doing that?

 

Thanks for any help, in advance.

if (!getInventory().isItemSelected()) {
	getInventory().getItem("steel bar").interact("Use");
	sleep(gRandom(400, 100));
} else {	
	if (getInventory().getSelectedItemName().equalsIgnoreCase("steel bar")) {
		getObjects().closest(FURN).interact("Smelt", "Use");
		sleep(gRandom(700, 100));
	}
|

Does the bot do this check automatically, or do I have to do that check within my script?

Thank you for your help!

on its own, but if you can do it too by easily opening setting tab

Edited by Joseph

  • Author

Thanks a lot Joseph! You da best.

I'll update this post if I've fixed it, still a good 'ol begginner so it's been rough. :)


!getEquipment().isWearingItem(EquipmentSlot.RING)

  • Author
!getEquipment().isWearingItem(EquipmentSlot.RING)

Your comment came in a the perfect time. ily <3

Your comment came in a the perfect time. ily QwPha8E.png

getEquipment().equip(EquipmentSlot.RING,"Ring of dueling(8)");
getEquipment().equip(EquipmentSlot.RING,"Ring of dueling(8)");

what does that method do? to lazy to check lol. 

what does that method do? to lazy to check lol. 

equips it  idk it works for me

 

 

This is how i use it

if (!getTabs().getOpen().equals(Tab.INVENTORY)) getTabs().open(Tab.INVENTORY);
        getEquipment().equip(EquipmentSlot.RING,"Ring of dueling(8)");

Edited by TheObserver

  • Author

Alright, last error I am getting:

The method closest(Filter<RS2Object>...) in the type EntityAPI<RS2Object> is not applicable for the arguments (RS2Object)
RS2Object DOOR = objects.closest("Door");

getObjects().closest(DOOR).interact("Open", "Use");

I assume I am initializing DOOR incorrect to work with the closest method, but not too sure how to go about fixing it.

Alright, last error I am getting:

The method closest(Filter<RS2Object>...) in the type EntityAPI<RS2Object> is not applicable for the arguments (RS2Object)
RS2Object DOOR = objects.closest("Door");

getObjects().closest(DOOR).interact("Open", "Use");

I assume I am initializing DOOR incorrect to work with the closest method, but not too sure how to go about fixing it.

objects.closest is the same thing as getObjects().closest so basically what you're doing now is getObjects().closest(objects.closest("Door"))

Also, the return value of objects.closest can be null so you should check for that before calling interact :)

  • Author

objects.closest is the same thing as getObjects().closest so basically what you're doing now is getObjects().closest(objects.closest("Door"))

Also, the return value of objects.closest can be null so you should check for that before calling interact smile.png

Welp, didn't even realize that. Thanks for getting me there, and the helpful tip :D

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.