wkmac 0 Share Posted October 26, 2015 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 Easelpublic 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 More sharing options...
Stormscythe 263 Share Posted October 26, 2015 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.