Jump to content
Parabot - Bot for Ikov, DreamScape, SoulPlay, RuneWild, and more
  • 0
lickanart

Help with getClosest(npc id) error

Question

Im getting this error in my command prompt then script stops. 

code is:

public void execute(){
    Npc seatroll = Npcs.getClosest(3847); // 10070 shadow king 3847 sea troll king
    if(seatroll != null){
        seatroll.interact(1);
        Time.sleep(2000);
        Time.sleep(new SleepCondition(){
            public boolean isValid() {
                return Players.getMyPlayer().isInCombat();
            }
        }, 3215);
    }
}

errors.png

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 1
9 hours ago, lickanart said:

Im getting this error in my command prompt then script stops. 

code is:

public void execute(){
    Npc seatroll = Npcs.getClosest(3847); // 10070 shadow king 3847 sea troll king
    if(seatroll != null){
        seatroll.interact(1);
        Time.sleep(2000);
        Time.sleep(new SleepCondition(){
            public boolean isValid() {
                return Players.getMyPlayer().isInCombat();
            }
        }, 3215);
    }
}

errors.png

public void execute(){
	try {
		Npc[] seatroll = Npcs.getNearest(3847); // 10070 shadow king 3847 sea troll king
		if(seatroll != null && seatroll.length > 1) {
			seatroll[0].interact(1);
			Time.sleep(new SleepCondition(){ 
            	public boolean isValid() { 
                	return Players.getMyPlayer().isInCombat(); 
                } 
            }, 3215);
		}
	} catch (NullPointerException e) {
		e.printStackTrace();
	}
}

 

Share this post


Link to post
Share on other sites
  • 0
6 hours ago, lickanart said:

Im getting this error in my command prompt then script stops. 

code is:

public void execute(){
    Npc seatroll = Npcs.getClosest(3847); // 10070 shadow king 3847 sea troll king
    if(seatroll != null){
        seatroll.interact(1);
        Time.sleep(2000);
        Time.sleep(new SleepCondition(){
            public boolean isValid() {
                return Players.getMyPlayer().isInCombat();
            }
        }, 3215);
    }
}

errors.png

Use .getNearest

 

Why are you using 2 sleep timers?

 

Time.sleep(2000);
        Time.sleep(new SleepCondition(){
            public boolean isValid() {
                return Players.getMyPlayer().isInCombat();
            }
        }, 3215);

 

 

Edited by cyanic

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...