measuring time

Posted by Thebloodsiren on Thu 06 Feb 2003 11:15 AM — 5 posts, 20,690 views.

#0
The mud i play requires a certain number of hours per month to be played minumum.

How would I create some sort of time reading device that records what time I log on and log off and then calculates and adds this to my monthly total?
Australia Forum Administrator #1
Make a small plugin that gets the time on connection, and saves it into a variable. Make another that gets the time on disconnection. Find the difference. Add to a MUSHclient variable. Have the plugin save its state. Then that should gradually keep track of your connection time.
#2
Sounds easy enough that I might be able to do it myself.
Can you make a trigger to catch the world.note stuff
--- Connected on Friday, February 07, 2003, 8:52 AM ---
and the disconnected message and then find the difference between them? I seem to be having troubles getting a trigger to match.

Otherwise do I need to use some function to get the system or world time. Like world.gettime if that existed.

Ta
#3
Since no scripting language is mentioned, I'll just throw out that you can use the function Now() in VBScript to get your current date/time of your system.
Australia Forum Administrator #4
Quote:

Can you make a trigger to catch the world.note stuff
--- Connected on Friday, February 07, 2003, 8:52 AM ---
and the disconnected message and then find the difference between them? I seem to be having troubles getting a trigger to match.


Those messages are world "notes" and triggers only match on incoming text from the MUD, so that won't work. However MUSHclient provides a "callback" for world connect and disconnect, so simply put a script function for both of them. Something like this, although I haven't tested it ...


dim connect_time

connect_time = Now  ' in case already connected

sub OnConnect
  connect_time = Now
end sub

sub OnDisconnect
dim Elapsed, TotalConnected

'
'  get connected time in minutes
'

  Elapsed = DateDiff ("m", connect_time, Now)

'
'  find previous connected time
'
 
  TotalConnected = CLng (world.GetVariable ("connected_time"))

'
'  add new time
'

  TotalConnected = TotalConnected + CLng (Elapsed)

'
'  save new time
'

  world.SetVariable "connected_time", TotalConnected

end sub