Jump to content

interface help


Recommended Posts

Posted

Hi everybody,

 

I need some help, I'm trying to make a monkfighter that will auto heal itself on the monk itself,

now i already have this bit of code: 

private void heal() throws InterruptedException {
	  NPC Monk = (NPC)this.npcs.closest(new String[] { "Monk" });
		if(Monk != null && !myPlayer().isUnderAttack() && !Monk.isUnderAttack()) {
			Monk.interact(new String[] { "Talk-to" });
			this.status = "healing at Monk";
		    getInterfaces().get(231).getChild(2).interact(new String[] { "continue" });
		    getInterfaces().get(219).getChild(1).interact(new String[] { "can" });
		    sleep(random(200,300));
		    getInterfaces().get(217).getChild(2).interact(new String[] { "continue" });
		    sleep(random(200,300));
		    getInterfaces().get(231).getChild(2).interact(new String[] { "continue" });
		    sleep(random(1000, 1500));
		}
	}

but in the loop when its opening the interfaces and starting to interact at "can", the onloop method refers back to this method so it will all start over again, meaning it will never go further than this line:

getInterfaces().get(231).getChild(2).interact(new String[] { "continue" });
 

so how do i do this?

thanks in advance,

 

Jelleplomp

Posted (edited)

You are getting an NPE error (nullpointer Exception)

 

If (231,2) doesn't get found it will return null.

So you do null.interact("Continue"); (and you can't really interact with something that doesn't exist right?)

 

You should stop using interfaces since the are deprecated.

Use RS2Widget instead.

 

You basicly to this:

RS2Widget chat1 = widgets.get(231,2)
if(chat1 != null && chat1.isVisible())
   chat1.interact("Continue");

Why are you using: (Did you decompile code? Decompilers generate this kind of code)

.interact(new String[] { "Continue" });

You can just do:

.interact("Continue");

Goodluck!

Khaleesi

Edited by Khaleesi
Posted

Umm, this should work; // Didn't test

if (!myPlayer().isInteracting(monk))) { // NOT INTERACTING
     if (monk != null) { // IF EXISTS
         if (monk.isVisible()) { // IS VISIBLE
             if (!dialogues.inDialogue()) { // NOT IN DIALOGUE
        monk.interact("Talk-to"); // INTERACTS
        log("Talking to monk"); // LOG
        sleep(random(500, 900)); // SLEEPS

}
}
} else if (dialogues.inDialogue()) { // IF IN DIALOGUE
               dialogues.clickContinue(); // CLICKS ON THE CONTINUE
               sleep(random(600, 1000)); //  SLEEPS
               dialogues.selectOption("Ok"); // GIVE THIS AN OPTION
               sleep(random(2500, 3500)); // SLEEPS
             }
} 

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