Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Need help on xp tracker


    IcCookies

    Recommended Posts

    Posted

    Hello everyone,

    How would I add an xp tracker to my bot?

     

    Right now i have:

     

    public int start(){
    return getSkillTracker().start(Skill.MINING);
    }
     
    public long stat(){
    return getSkillTracker().getGainedExperience(Skill.MINING);
    }
     
     
    but it says it can't return a void result.
    I am a beginner scripter and would gladly accept some help please!
    Posted

    public void onPaint(Graphics2D g) {

    g.setFont(font);
    g.setColor(Color.BLACK);

     

    g.drawString("" +getSkillTracker().getGainedExperience(Skill.MINING), x, y);

    }

     

    /* This is to paint it on the client screen */

    Posted

    private int xpBegan;
    private int xp;



    onstart

    xpBegan = getSkills().getExperience(Skill.ATTACK) + getSkills().getExperience(Skill.STRENGTH) + getSkills().getExperience(Skill.DEFENCE) + getSkills().getExperience(Skill.HITPOINTS);

    onpaint

    xp = (getSkills().getExperience(Skill.ATTACK) + getSkills().getExperience(Skill.STRENGTH) + getSkills().getExperience(Skill.DEFENCE) + getSkills().getExperience(Skill.HITPOINTS)) - xpBegan;

    int xph = (int) (xp / ((timeRan) / 3600000.0D));

    now draw it

    g.drawString("xp = " + NumberFormat.getNumberInstance(Locale.US).format(xp), 345 + 2, 341 + 30);
    g.drawString("xph = " + NumberFormat.getNumberInstance(Locale.US).format(xph), 345 + 2, 341 + 48);
    Posted

     

    Hello everyone,

    How would I add an xp tracker to my bot?

     

    Right now i have:

     

    public int start(){

    return getSkillTracker().start(Skill.MINING);

    }

     

    public long stat(){

    return getSkillTracker().getGainedExperience(Skill.MINING);

    }

     

     

    but it says it can't return a void result.

    I am a beginner scripter and would gladly accept some help please!

    Change start from int to void. That method probably doesn't return an int. Just run the method without any return

    Posted

    I put in 

    g.drawString("Mining exp: " + getSkillTracker().getGainedExperience(Skill.MINING), 5, 85);

    and all it does is print out the total xp that I have!!!

    Posted

    I put in 

    g.drawString("Mining exp: " + getSkillTracker().getGainedExperience(Skill.MINING), 5, 85);

    and all it does is print out the total xp that I have!!!

    then just forgot that method and use the one I have pasted above and replace the combat stats with the mining stat.

    Posted

    I put in

    g.drawString("Mining exp: " + getSkillTracker().getGainedExperience(Skill.MINING), 5, 85);

    and all it does is print out the total xp that I have!!!

    This happens if you start the script without being logged in to the client, as it starts the skill tracker on script start if you put it in onStart()

    Posted

    The original problem you were asking about:

    public int start(){
    return getSkillTracker().start(Skill.MINING);
    }
     
    getSkillTracker().start is a void method, it doesn't return anything.
    You're trying to return a void method, so just remove the return and change the method to a void.
     
    public void start(){
    getSkillTracker().start(Skill.MINING);
    }
    Posted

     

    The original problem you were asking about:

    public int start(){
    return getSkillTracker().start(Skill.MINING);
    }
     
    getSkillTracker().start is a void method, it doesn't return anything.
    You're trying to return a void method, so just remove the return and change the method to a void.
     
    public void start(){

    getSkillTracker().start(Skill.MINING);

    }

     

    So can I do this or is there still a problem:

     

    public void onPaint(Graphics2D g) {
    g.drawString("Mining exp: " + xp, 5, 85);
    }
    public void xp(){
    getSkillTracker().start(Skill.MINING);
    }
     
    Posted

     

    So can I do this or is there still a problem:

     

    public void onPaint(Graphics2D g) {
    g.drawString("Mining exp: " + xp, 5, 85);
    }
    public void xp(){
    getSkillTracker().start(Skill.MINING);
    }
     

     

    I would suggest you learn Java before you try to learn how to script. It'll make the process go much smoother.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.