Jump to content

Idle script


Tikvesa

Recommended Posts

15 hours ago, Tikvesa said:

lol, are you gonna fix it?
I know you said in discord that u dont support old scripts anymore

//This is the start time
long startTime = System.currentTimeMillis();


//Get run time in seconds - Use some other method to format it as hh:mm:ss
(System.currentTimeMillis() - startTime) / 1000

You can implement this code into the code @Nbaconsent

Edited by Medusa
Link to comment
Share on other sites

4 minutes ago, Medusa said:

//This is the start time
long startTime = System.currentTimeMillis();


//Get run time in seconds - Use some other method to format it as hh:mm:ss
(System.currentTimeMillis() - startTime) / 1000

You can implement this code into the code @Nbaconsent

yes i followed pugs tutorial for timer i got it working.
 

public class Main extends Script {
	private long timeBegan;
	private long timeRan;

	
	public void onStart(){
		timeBegan = System.currentTimeMillis();
		
	}
	
	public int waitTime(int min, int max) {
		return (int)(Math.random() * (max - min)) + min;
	}
	
	public int onLoop() throws InterruptedException {
		if (mouse.isOnScreen()) {
			mouse.moveOutsideScreen();
		} else {
			mouse.move((int)(100 + (Math.random() * 660)), (int)(100 + (Math.random() * 400)));
		}
		
		return waitTime(1000, 240000); //1 sec to 4 mins.
	}
	public void onPaint(Graphics2D g)
    {
      Graphics2D gr = g;
      timeRan = System.currentTimeMillis() - this.timeBegan; 
      g.drawString(ft(timeRan), 1, 250); 
    }
    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 + "h " + minutes + "m " + seconds+ "s ");
        } 
        else 
        {
            res = (days + "d " + hours + "h " + minutes + "m " + seconds+ "s ");
        }
        return res;
  
    }
        
 
 
}

This is my whole script and its working fine. Now im trying to log how long did script last for in console but i cant get time in h m s im getting it in pure ms. How to fix it?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...