Is there a function that gets the time since the last input command?

Posted by SKYY on Tue 08 Apr 2008 01:09 AM — 6 posts, 23,344 views.

#0
What the title says. Search hasn't helped me, and I want something for making a safe idling timer.

For example, the timer would look at the amount of time since the last triggered or typed-in command, and if that time exceeds a certain amount (15 minutes or so) it would input something like "save;afk".

Any advice?

Thanks in advance.
Australia Forum Administrator #1
I searched for "afk timer". This is one of the posts:

http://www.gammon.com.au/forum/?id=5964
#2
I looked at that one, but it seemed like it wasn't automatic--ie. you had to manually set the timer on or off. I'm trying to make a plugin that IS automatic, ie. it knows how long since you've entered a command, and it sets you AFK when that time is past a certain amount.

Or does that plugin you wrote do just that?

Thanks.
USA #3
It looks pretty automatic to me, once the plugin is enabled... The plugin takes care of managing the timer for you, you don't have to do it yourself.
Australia Forum Administrator #4
It would be hardly much use if you had to manually do it, would it?

The important part is here:


-- when they type something, reset AFK status

function OnPluginCommand (sText)
  FixTimer ()
  return true  -- process the command
end


Every time you enter a command it resets the timer. Thus effectively it remembers the time of the last command. If you don't enter a command for the desired period then the timer fires and sends the required message to the MUD.
#5
I'm a moron. Heh--thanks!