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

Timer class

Featured Replies

A Timer class would be helpful and would remove the need for unnecessary code in scripts.
 
Use Case:
 
Usual

if(object.interact(...)) {
	script.sleep(...);
	//Guess how long action will take - no time out.
	//if action takes 1 second, but your script is sleeping for 3 seconds.
	//That would add up to a lot of time wasted.

        //Validate action completed and handle accordingly

}

With Timer

if(object.interact(...)) {
	Timer timer = new Timer(4000); //4 second timeout
	while(timer.isRunning() && Condition) //stops when action completed, or timeout reached.
		script.sleep(50);
	//Validate action completed and handle accordingly
}

Just Something as simple as:

public class Timer {

	private long period, start;

	public Timer(long period) {
		this.period = period;
	}

	public long getElapsed(){
		return System.currentTimeMillis()-start;
	}

	public long getRemaining(){
		return period-getElapsed();
	}

	public boolean isRunning(){
		return getElapsed() <= period;
	}

	public void reset(){
		start = System.currentTimeMillis();
	}

	public long setEndIn(long ms){
		return period = ms;
	}

	public static String format(long milliSeconds) {
		long secs = milliSeconds/1000;
		return String.format("%d:%02d:%02d", secs/3600, (secs%3600)/60, (secs%60));
	}
}

Edited by Cory

yeah it will help in dynamic sleeps and they are better than static sleeps smile.png

maybe some thing like this 

 

You do realize that the timer resets every 24 hours and it's not even clean?

Edited by Peter

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.