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
  • Help with paint calculation problem


    wkmac

    Recommended Posts

    One quick questions.

     

    When i start my script im getting this as my time elapsed and the rs client freezes.

     

    http://prntscr.com/8viz6z

     

    Here is the code thats causing it:

    public void onPaint(Graphics g1) {
    timeRan = System.currentTimeMillis() - timeBegan;
    Graphics2D g = (Graphics2D)g1;
    g.setColor(color1);
    g.fillRect(325, 226, 190, 110);
    g.setColor(color2);
    g.setStroke(stroke1);
    g.drawRect(325, 226, 190, 110);
    g.setFont(font1);
    g.setColor(color3);
    g.drawString("Mac's Pest Control", 380, 240);
    g.drawString("Points earned: " + pointsEarned, 330, 280);
    g.drawString("Time running: " + ft(timeRan), 330, 260);
    g.drawString("Points per hour: " + pointsPerHour(timeRan, pointsEarned), 330, 300);
    g.drawString("Thank you for using my script.", 350, 330);
    }
    //END: Code generated using Enfilade's Easel

    public String ft(long duration)
    {
    String res = "";
    long days = TimeUnit.MILLISECONDS.toDays(duration);
    long hours = TimeUnit.MILLISECONDS.toHours(duration)
    - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
    long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
    - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
    .toHours(duration));
    long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
    - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
    .toMinutes(duration));
    if (days == 0) {
    res = (hours + ":" + minutes + ":" + seconds);
    } else {
    res = (days + ":" + hours + ":" + minutes + ":" + seconds);
    }
    return res;
    }


    public long pointsPerHour(long timeRan, int points){
    long time = (int) ((timeRan / (1000*60*60)) % 24);
    long answer = points/time;
    return answer;
    }

    This is confusing the hell out of me because when i remove the pointsPerHour method it works fine. My question is why the pointsperhour method is affecting the ft method

     

    Link to comment
    Share on other sites

     

    One quick questions.

     

    When i start my script im getting this as my time elapsed and the rs client freezes.

     

    http://prntscr.com/8viz6z

     

    Here is the code thats causing it:

    public void onPaint(Graphics g1) {

    timeRan = System.currentTimeMillis() - timeBegan;

    Graphics2D g = (Graphics2D)g1;

    g.setColor(color1);

    g.fillRect(325, 226, 190, 110);

    g.setColor(color2);

    g.setStroke(stroke1);

    g.drawRect(325, 226, 190, 110);

    g.setFont(font1);

    g.setColor(color3);

    g.drawString("Mac's Pest Control", 380, 240);

    g.drawString("Points earned: " + pointsEarned, 330, 280);

    g.drawString("Time running: " + ft(timeRan), 330, 260);

    g.drawString("Points per hour: " + pointsPerHour(timeRan, pointsEarned), 330, 300);

    g.drawString("Thank you for using my script.", 350, 330);

    }

    //END: Code generated using Enfilade's Easel

     

    public String ft(long duration)

    {

    String res = "";

    long days = TimeUnit.MILLISECONDS.toDays(duration);

    long hours = TimeUnit.MILLISECONDS.toHours(duration)

    - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));

    long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)

    - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS

    .toHours(duration));

    long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)

    - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS

    .toMinutes(duration));

    if (days == 0) {

    res = (hours + ":" + minutes + ":" + seconds);

    } else {

    res = (days + ":" + hours + ":" + minutes + ":" + seconds);

    }

    return res;

    }

     

     

    public long pointsPerHour(long timeRan, int points){

    long time = (int) ((timeRan / (1000*60*60)) % 24);

    long answer = points/time;

    return answer;

    }

    This is confusing the hell out of me because when i remove the pointsPerHour method it works fine. My question is why the pointsperhour method is affecting the ft method

     

     

    Not sure if this will solve your problem, but you could just use a regular timer for this:

    //Make a global variable:
    
    Timer t;
    
    //put this in your onStart()
    t = new Timer();
    
    //Now in the onPaint do this:
    
    g.drawString("Time Running: " + t.formatTime(), 330,260);
    
    
    
    Link to comment
    Share on other sites

    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.