mIRC Home    About    Download    Register    News    Help

Print Thread
duration of an event #24125 14/05/03 02:41 AM
Joined: Feb 2003
Posts: 48
B
brad2 Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2003
Posts: 48
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!!

Re: duration of an event #24126 14/05/03 02:47 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
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))

Last edited by ScatMan; 14/05/03 02:48 AM.
Re: duration of an event #24127 14/05/03 03:08 AM
Joined: Feb 2003
Posts: 48
B
brad2 Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2003
Posts: 48
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"

Re: duration of an event #24128 14/05/03 03:15 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
well, u forgot the set the variable
//set %awaytime $ctime

Re: duration of an event #24129 14/05/03 03:18 AM
Joined: Feb 2003
Posts: 48
B
brad2 Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2003
Posts: 48
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.

Re: duration of an event #24130 14/05/03 03:49 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
$duration($calc($ctime - %awaytime))

Re: duration of an event #24131 14/05/03 03:54 AM
Joined: Apr 2003
Posts: 426
neophyte Offline
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
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!


--------
mIRC - fun for all the family (except grandma and grandpa)
Re: duration of an event #24132 14/05/03 04:28 AM
Joined: May 2003
Posts: 730
S
ScatMan Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: May 2003
Posts: 730
no, i think it's better to use that way with the $ctime
and brad2 i copied my command wrong

Re: duration of an event #24133 14/05/03 04:33 AM
Joined: Apr 2003
Posts: 426
neophyte Offline
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
I can see your point. But for those of use who are lazy :P


--------
mIRC - fun for all the family (except grandma and grandpa)
Re: duration of an event #24134 14/05/03 04:41 AM
Joined: Dec 2002
Posts: 699
N
Nimue Offline
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
"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.


Re: duration of an event #24135 14/05/03 04:45 AM
Joined: Apr 2003
Posts: 426
neophyte Offline
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
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


--------
mIRC - fun for all the family (except grandma and grandpa)
Re: duration of an event #24136 14/05/03 10:44 AM
Joined: May 2003
Posts: 3
C
ChamuR Offline
Self-satisified door
Offline
Self-satisified door
C
Joined: May 2003
Posts: 3
just use - $duration($awaytime)
-


It's not that I'm afraid to die, I just don't want to be there when it happens.
Re: duration of an event #24137 14/05/03 03:23 PM
Joined: Feb 2003
Posts: 48
B
brad2 Offline OP
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Feb 2003
Posts: 48
Thanks! I put this in: $duration($calc($ctime - %awaytime))

I had the $ctime and %awaytime backwards. Works perfect now!

Re: duration of an event #24138 14/05/03 11:17 PM
Joined: Apr 2003
Posts: 426
neophyte Offline
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
$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.


--------
mIRC - fun for all the family (except grandma and grandpa)
Re: duration of an event #24139 15/05/03 02:41 AM
Joined: Jan 2003
Posts: 3,012
KingTomato Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
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)



-KingTomato
Re: duration of an event #24140 15/05/03 08:44 AM
Joined: Apr 2003
Posts: 426
neophyte Offline
Fjord artisan
Offline
Fjord artisan
Joined: Apr 2003
Posts: 426
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.


--------
mIRC - fun for all the family (except grandma and grandpa)
Re: duration of an event #24141 15/05/03 01:09 PM
Joined: May 2003
Posts: 3
U
uLiKo Offline
Self-satisified door
Offline
Self-satisified door
U
Joined: May 2003
Posts: 3
Just tested it with the exact same alias you used and it worked perfectly every time.

Re: duration of an event #24142 15/05/03 09:15 PM
Joined: Feb 2003
Posts: 2,642
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,642
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


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: duration of an event #24143 15/05/03 09:27 PM
A
Anonymous
Unregistered
Anonymous
Unregistered
A
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