mIRC Homepage
Posted By: brad2 duration of an event - 14/05/03 02:41 AM
OK, I am thoroughly confused on this one.

I have been fiddling around making a few scripts. I made a "away" script. (It does not use mIRC's away system though)

I have it set where whenever I type "/away" it changes my name to "Nick-away", and it sets a timer (%awaytime).

I also have it where whenever someone queries me, it displays a message (I am not here.)

Now, my question.

How can I take the current time, and subtract the %awaytime, so it will display how many hours, minutes, seconds I have been "away".

Basically, I want to take the current time, and subtract a set variable from it.

PLEASE HELP!!
Posted By: ScatMan Re: duration of an event - 14/05/03 02:47 AM
when u are /away u can set a variable with $ctime
set %awaytime $ctime
and when u're back u can return the time u are away with
$duration($calc($ctime - %awaytime))
Posted By: brad2 Re: duration of an event - 14/05/03 03:08 AM
ok, I did that, "$duration($calc($ctime - %awaytime))"
and it returned it in this format: "I have been away for -126secs"

How can I make it say "2mins 06secs"
Posted By: ScatMan Re: duration of an event - 14/05/03 03:15 AM
well, u forgot the set the variable
//set %awaytime $ctime
Posted By: brad2 Re: duration of an event - 14/05/03 03:18 AM
Code:
 
alias away2 {
  if (.server.net isin $server) {
    /nickaway
    /set %awaytime $ctime
  }
}
 


Code:
on 1:TEXT:*:?:{
  if (away isin $me) {
    /query -n $nick I am not here right now. I have been away for $duration($calc(%awaytime - $ctime))
  }
}
 


that is what i have. It works right, it just doesn't display the time in the right format.
Posted By: Nimue Re: duration of an event - 14/05/03 03:49 AM
$duration($calc($ctime - %awaytime))
Posted By: neophyte Re: duration of an event - 14/05/03 03:54 AM
wouldn't it just be simpler to create a timer that runs every second and increments a variable? then use $duration to get the time?!


it takes two lines of code!

set %awaytime 0
.timerAwaytime 0 1 { inc %awaytime 1 }



then all you have to do is use $duration(%awaytime) to get your total time away!
Posted By: ScatMan Re: duration of an event - 14/05/03 04:28 AM
no, i think it's better to use that way with the $ctime
and brad2 i copied my command wrong
Posted By: neophyte Re: duration of an event - 14/05/03 04:33 AM
I can see your point. But for those of use who are lazy :P
Posted By: Nimue Re: duration of an event - 14/05/03 04:41 AM
"wouldn't it just be simpler to create a timer that runs every second and increments a variable?"
You don't need a timer to do that, /inc -c %varname

/help /inc
/inc [-cszuN] <%var> [value]
This increases the value of %var by value.

If you specify the -uN switch, %var is increased by the value once and then %var is unset N seconds later, assuming it is not set again by another script.

The [color:#0000C9]-c switch increases %var once per second.[/color]

The -z switch decreases %var until it reaches zero and then unsets it.

Posted By: neophyte Re: duration of an event - 14/05/03 04:45 AM
True... I'd completely forgotten :P



But I like the $ctime one now that I've been mucking around with it...


I dislike variables alot now :P
Posted By: ChamuR Re: duration of an event - 14/05/03 10:44 AM
just use - $duration($awaytime)
-
Posted By: brad2 Re: duration of an event - 14/05/03 03:23 PM
Thanks! I put this in: $duration($calc($ctime - %awaytime))

I had the $ctime and %awaytime backwards. Works perfect now!
Posted By: neophyte Re: duration of an event - 14/05/03 11:17 PM
$duration($awaytime) won't work if you've got a script that marks you back and does a lot of other things.


Just try it and you'll see what I mean.

for instance:

alias markback {
msg $chan i'm back (after $duration($awaytime) $+ )
away
}

The above code will not return your time spent away, simply because of how a script is executed.

Of course, it may just be my experiences, but I'm fairly confident that you can't really use $awaytime.
Posted By: KingTomato Re: duration of an event - 15/05/03 02:41 AM
Excuse me guys, but please read:

Quote:

I have been fiddling around making a few scripts. I made a "away" script. (It does not use mIRC's away system though)

Posted By: neophyte Re: duration of an event - 15/05/03 08:44 AM
I am aware of that.

I was merely pointing out that $awaytime won't work if you try and use it in a back msg.
Posted By: uLiKo Re: duration of an event - 15/05/03 01:09 PM
Just tested it with the exact same alias you used and it worked perfectly every time.
Posted By: Raccoon Re: duration of an event - 15/05/03 09:15 PM
I personally will never understand the purpose of announcing that you are Away or Back, unless of corse you were in the midst of a conversation and had to run AFK quickly.

Most people are uninterested if you go Away, especiall if it's automatically after N minutes of inactivity. If someone really wants to know if you're away, they will type: /Whois <YourNick> <YourNick> (putting your nickname twice, will query your remote server directly... which includes your away status and idle time)

I know smaller channels might be alright with posting /away and /back messages, but please keep in mind that most channels really Dont Care if you're away. </rant>

- Raccoon
Posted By: Anonymous Re: duration of an event - 15/05/03 09:27 PM
Quote:
/Whois <YourNick> <YourNick> (putting your nickname twice, will query your remote server directly... which includes your away status and idle time)

heh ... learn something new everyday
© mIRC Discussion Forums