Jump to content

Get current object myPlayer is interacting with


Recommended Posts

Posted
1 hour ago, Nbacon said:

Hey pigfarmer,

I don't know if this works 


 public RS2Object something() {


        for (RS2Object x:getObjects().getAll()) {
            if (myPlayer().isInteracting((org.osbot.rs07.api.model.Character<?>) x)){
                return x;
            }

        }
        
        return null;
    }

Also you might want to put questions in https://osbot.org/forum/forum/249-scripting-help/ not https://osbot.org/forum/forum/251-snippets/ 

 

This dose not work unfortunately:(

It seems like you can not cast a RS2Object to a Character :(

Anyone else that knows who this could be done???

Posted
On 6/9/2020 at 3:08 PM, pigfarmer said:

I just want to know if the bot is interacting with a object and if so, what is the object?

Try this

Entity interacting = myPlayer().getInteracting();
if (interacting != null) {
    if (interacting instanceof RS2Object) {
        RS2Object object = (RS2Object) interacting;
    } else if (interacting instanceof NPC) {
        NPC npc = (NPC) interacting;
    }
}
  • Heart 1
  • 7 months later...

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