Jump to content

Get the total lvl


IkiritokunI

Recommended Posts

Dear community!

 

I got another question about getting my bot look at the total lvl

we all know we can get static/dynamic skills like this:

(getSkills().getDynamic(Skill.MINING) 

But I not found out yet how to get the bot look a total lvl

Maybe a widget or is there a code for it?

 

Thanks for the help!

 

Link to comment
Share on other sites

Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... 

int totalLevel = 0;

for( Skill skill : Skill.values() ){
	totalLevel += getSkills().getStatic(skill);
}

log("My total level is " + totalLevel); 

 

Edited by jca
Link to comment
Share on other sites

5 minutes ago, jca said:

Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... 


int totalLevel = -1;

for( Skill skill : Skill.values() ){
	totalLevel += getSkills().getStatic(skill);
}

log("My total level is " + totalLevel); 

 

Thanks! I will try this! <3

Link to comment
Share on other sites

2 hours ago, jca said:

Not sure if there is a method in the Skills API, I can't seem to find one, but you could do something like this... 


int totalLevel = -1;

for( Skill skill : Skill.values() ){
	totalLevel += getSkills().getStatic(skill);
}

log("My total level is " + totalLevel); 

 

 

That's going to be off by 1, totalLevel should be initialised to 0

Alternative using streams:
 

int totalLevel = Arrays.stream(Skill.values())
                       .mapToInt(skill -> getSkills().getStatic(skill))
                       .sum();



 

Edited by Explv
  • Like 3
Link to comment
Share on other sites

2 hours ago, liverare said:

*ahem* getSkills()::getStatic

*drops mic*

 

Now for the true s3 way to do it

private final static int MAX_TOTAL_LEVEL = 2277;

public int getTotalLevel(){

  int totalLevel = MAX_TOTAL_LEVEL;
  for(int i = 0; i < Skill.values().length; i++){
      totalLevel -= 99 - getSkills().getStatic(Skill.values()[i]);  
  }
  
  return totalLevel;
}

I'll see myself out, selling private scripts

Edited by Tom
  • Like 2
  • Boge 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...