Jump to content

Need help working out the timer for home tele


Alakazizam

Recommended Posts

38 minutes ago, dubai said:

I might be wrong but you could do something like:
If widget exists and contains message(int 1-20 minutes)

But another easy option could be to just store the time in memory from where you teleported and count down 20 mins?

I've never messed with the chat as widgets, I'll look into that. I usually use the onMessage() for anything having to do with chat. 

But I don't want to rely on storing it and having a timer because I'd worry about it not functioning as intended if I need to stop the script and start it back up for whatever reason.

Link to comment
Share on other sites

15 minutes ago, Khaleesi said:

The time the last home teleport is saved in a config 892 if I remember correctly, so you can always check that config :)

Yeah, I got that much sorted out. I'm trying to figure out how to get whatever the current time is to compare it to the time that was set. I thought I found it but I can only figure out how to get my own system's time.

 

Link to comment
Share on other sites

Here, taken from my quester :doge: 

	public int getSecondsLeftTeleportHome() {
		int lastTeleport = getConfigs().get(892);
		long lastTeleportSeconds = (long) lastTeleport * 60;
		Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(Duration.ofMinutes(30));
		Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
		return (int) remainingTime.getSeconds();
	}

 

  • Heart 2
Link to comment
Share on other sites

6 hours ago, Czar said:

Here, taken from my quester :doge: 

	public int getSecondsLeftTeleportHome() {
		int lastTeleport = getConfigs().get(892);
		long lastTeleportSeconds = (long) lastTeleport * 60;
		Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(Duration.ofMinutes(30));
		Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
		return (int) remainingTime.getSeconds();
	}

 

Awesome, that got me squared away. Also taught me about 'Instant' so thanks for that too!

  • Like 1
Link to comment
Share on other sites

13 hours ago, Czar said:

Here, taken from my quester :doge: 

	public int getSecondsLeftTeleportHome() {
		int lastTeleport = getConfigs().get(892);
		long lastTeleportSeconds = (long) lastTeleport * 60;
		Instant teleportExpireInstant = Instant.ofEpochSecond(lastTeleportSeconds).plus(Duration.ofMinutes(30));
		Duration remainingTime = Duration.between(Instant.now(), teleportExpireInstant);
		return (int) remainingTime.getSeconds();
	}

 

Nice spoon 😉 

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