mIRC Home    About    Download    Register    News    Help

Print Thread
#188752 30/10/07 01:44 AM
Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello,

I would like to make an alias that calculates my total time spent in a channel from join to part/quit

where I would go, $time.spent(#)

Could this be done using a timer? If so, what would it look like?

Thanks again

-J

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Why not just set a variable (or hash-table entry) with a $ctime when you join? Simple.
Code:
ON me:*:JOIN:#: {
  hadd -m timetrack $+($cid, !, #) $ctime
}
ON me:*:PART:#: {
  echo -s Spent $duration($calc($ctime - $hget(timetrack, $+($cid, !, #))) on #
  hdel timetrack $+($cid, !, #)
}

(Note: code untested)
(Edit: Removed stray '(').

Last edited by Bekar; 30/10/07 06:37 AM.
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
I'd just use a variable, less overhead...
Code:
on me:*:join:#:{ inc -c $+(%,timetrack,$cid,#) }
on me:*:part:#:{
  echo -s Spent $duration($($+(%,timetrack,$cid,#),2) on #
  unset $+(%,timetrack,$cid,#)
}


Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
smile

I don't particularly like variables, so try to code without relying upon them.

The old school of 'If your variables tab was wiped out'..

Besides, I'm usually on 30-40 channels over 5 networks.. Messy wink

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Originally Posted By: Bekar
smile
The old school of 'If your variables tab was wiped out'..

That's never happened to me wink


As a side note, if you did need to use a hash table, you can still use a similar code, saving on the $calc.
Code:
on me:*:join:#:{ hinc -mc timetrack $+($cid,#) }
on me:*:part:#:{
  echo -s Spent $duration($hget(timetrack,$+($cid,#))) on #
  hdel timetrack $+($cid,#)
}

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
How much overhead does the '-c' produce though, if you've got "many" such variables ? Is there a feasable limit to how many a given class of machine can run before it just gets a bit rediculas?

Nice code though smile

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
I doubt it would be any (significant amount) although I don't know how its coded.
My guess would be that it's much the same as setting the var to $ctime with mIRC only evaluting it when/as needed.

Joined: Oct 2007
Posts: 214
B
Fjord artisan
OP Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Thank you Guys, its amazing the 2 ways that this can be done, it's exactly what I am looking for. Thanks again.

- J


Link Copied to Clipboard