Timing an event

Posted by ErockMahan on Sat 20 Aug 2005 07:48 PM — 4 posts, 24,440 views.

#0
I know, I know, this seems like it would be something covered elsewhere, but to be honest, I can't find it. I found a plugin that will time how long it takes to get to the next level, but I couldn't modify that plugin sufficiently for my needs.

I want to create an experience/time calculator. Meaning, when a fight beins, I want to start a timer that will stop when the fight ends, then divide the number of experience points by that time.

It would be helpful if the result could be appended to a notepad too, but if everything else is script oriented, I should be able to do that (thank you for help with that, by the way).

For the sake of examples, let's say that something simple happens at the beginning of every fight like:

The fight has begun!

and ends with:

You recieve * experience points.

Thanks for all your help!
USA #1
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3362
That talks about Now and Time and stuff (for VBScript, other scripts deal with time in different ways).

But it also talks about how it works (and there are a lot of links, I havent followed any of them though).

If youre doing it by a timer, you're thinking about it wrong. Timers are like alarm clocks, not a stopwatch.
To act as a stopwatch, you need to store the start time, and then get the end time, and subtract.

Which script language you use depends on how exact you want to be. Some languages deal with time in milliseconds, some in seconds.

I wrote a plugin to append time differences (its only a plugin because it needs to tweak packets before interpretation). You can use the logic (or the subroutine to calculate) to do what you want. It's in JScript (since it needed milliseconds).
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=5567
#2
Wow, it took a lot of reading and lots of trying things, but I got it. It didn't come from any one source, so my thanks goes to many people, including you and Nick Gammon.

Now I just need to tweak it to perfection. It's nice that it all works, but now I'd like to change it to round off to two decimal places instead of floating. Here is the more important part of the code I wrote:


AppendToNotepad "stuff",vbcrlf
AppendToNotepad "stuff","%1 xp"
dim durationA
dim durationB
dim durationC
durationA = datediff("s",getvariable("durationstart"),time)
World.SetVariable "durationA", durationA
durationB = (Fix(durationA / 60))
durationC = (durationA - (durationB * 60))
world.EchoInput = 0
world.send "gt the fight took " & durationB & "mins " & durationC & "secs "
world.send "gt that is about " & %1 / durationA & " xp/sec"
world.EchoInput = 1




Thanks :)
USA #3
You can use SendNoEcho instead of toggling the echo value.

And you can use the function Round to round.