Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Basic Paint problem

Featured Replies

hi guys, so I am new to writing scripts and i have kind of a stupid question.

I wrote this basic goblin killing script and added some draws, for some reason though my timer always starts at 2 hrs.

Anyone knows why?

here is the code:

    	int totalXp = 0;
    	for(final Skill skill : new Skill[]{Skill.ATTACK, Skill.STRENGTH, Skill.DEFENCE, Skill.RANGED, Skill.MAGIC}) {
            totalXp += getExperienceTracker().getGainedXP(skill);
        }
    	Date date = new Date(getExperienceTracker().getElapsed(Skill.ATTACK));
    	DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
    	String dateFormatted = formatter.format(date);
    	g.drawString("Time Running: " + dateFormatted, 20, 300);
    	g.drawString("Total XP: " + Integer.toString(totalXp), 20, 330);

 

Never used the get elapsed on tracker, this is what I use for time and its always spot on

public void onStart(){
  startTime = System.currentTimeMillis();
}
public void onPaint(){
final long runTime = System.currentTimeMillis() - startTime;
  g.drawString("Time running: " + formatTime(runTime), 320, 400);
}
public final String formatTime(final long ms) {
		long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
		s %= 60;
		m %= 60;
		h %= 24;

		return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
				: h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s);
	}

 

  • Author
Just now, GPSwap said:

Never used the get elapsed on tracker, this is what I use for time and its always spot on


public void onStart(){
  startTime = System.currentTimeMillis();
}
public void onPaint(){
final long runTime = System.currentTimeMillis() - startTime;
  g.drawString("Time running: " + formatTime(runTime), 320, 400);
}
public final String formatTime(final long ms) {
		long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24;
		s %= 60;
		m %= 60;
		h %= 24;

		return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s)
				: h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s);
	}

 

ty though if anyone knows why it is adding 2 hrs I would appriciate it :)

might just do it like that if i dont find an answer

1 minute ago, HunterRS said:

ty though if anyone knows why it is adding 2 hrs I would appriciate it :)

might just do it like that if i dont find an answer

wish i had a answer for ya

  • Author
1 hour ago, liverare said:

The ExperienceTracker has a function start. You should run that for all of your skills onStart.

I did :),

here is also the onStart:

    public void onStart() {
    	log("Goblin killer has started");
        for(final Skill skill : new Skill[]{Skill.ATTACK, Skill.STRENGTH, Skill.DEFENCE, Skill.RANGED, Skill.MAGIC}) {
            getExperienceTracker().start(skill);
        }
    }

 

EDIT: just to be clear, it was all ready done before so that is not the problem.

Edited by HunterRS

you're over complicating things imo

for runtime:

	public long startTime = System.currentTimeMillis();

	public void onPaint(Graphics2D g) {
		g.drawString("Runtime: " + Time.msToString(System.currentTimeMillis() - startTime), x, y);
	}

	public static String msToString(long ms) {
		int time = (int) (ms / 1000L);
		int h = time / 3600;
		int m = time / 60 % 60;
		int s = time % 60;
		return (h < 10 ? "0" + h : Integer.valueOf(h)) + ":" + (m < 10 ? "0" + m : Integer.valueOf(m)) + ":"
				+ (s < 10 ? "0" + s : Integer.valueOf(s));
	}

for xp trackers just use:

getExperienceTracker().getGainedXP()

getExperienceTracker().getGainedXPPerHour()

getExperienceTracker().getTimeToLevel()

Edited by superuser

1 hour ago, superuser said:

 

A simpler msToString method (takes seconds tho, so need to do ms/1000 first):

	/**
	 * Formats seconds into a H:MM:SS timestamp
	 * @param seconds
	 * @return
	 */
	public static String formatTime(long seconds) {
		if (seconds <= 0)
			return "00:00:00";
		return String.format("%d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, (seconds % 60));
	}

 

Edited by Lemons

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.