mIRC Home    About    Download    Register    News    Help

Print Thread
How long users been in Channel #202740 29/07/08 07:27 AM
Joined: Jul 2008
Posts: 3
S
Soopy Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Jul 2008
Posts: 3
i cant figure this out...i have used $uptime but i cant figure out how to get it so when people use !uptime it will show how long they have been in the channel for.

would i have to create a timer that counts up somehow?

any help would be appreciated. thanks.

Re: How long users been in Channel [Re: Soopy] #202741 29/07/08 08:02 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
First off, $uptime doesn't report how long a person has been in a channel.
Code:
on me:*:join:#:{
  var %a = 1, %b = $nick($chan,0)
  while %a <= %b {
    .hadd -m Time $+($network,.,$chan,.,$nick($chan,%a)) $ctime
    inc %a
  }
}
on !*:join:#:{
  .hadd -m Time $+($network.,.$chan,.,$nick) $ctime
}
on *:text:!uptime:#:{
  .notice $nick You have been in $chan for $duration($calc($ctime - $hget(Time,$+($network,.,$chan,.,$nick))))
}
on *:start:{
  .scon -at1 init_time $!cid
}
alias -l init_time {
  .scid $1
  var %a = 1, %b = $chan(0)
  while %a <= %b {
    var %c = 1, %d = $nick($chan(%a),0)
    while %c <= %d {
      .hadd -m Time $+($network,.,$chan(%a),.,$nick($chan(%a),%c)) $ctime
      inc %c
    }
    inc %a
  }
}

This is a bit more complex than what you actually asked for, but it does track the time for the person in the channel, and is multi-network ready. It also will set the initial start times when the code is started, no need to disconnect from any network or part any channels for it to start, but note that the time reported will only be from the most recent of a) the script being started, b) you joining the channel, c) the time the nick joined the channel.
There is no way for the script to know how long a person had been in the channel before the script was started or before you joined with the script running.

Re: How long users been in Channel [Re: RusselB] #202742 29/07/08 08:12 AM
Joined: Jul 2008
Posts: 3
S
Soopy Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Jul 2008
Posts: 3
thanks RusselB. i really appreciate it.

Re: How long users been in Channel [Re: Soopy] #202744 29/07/08 10:27 AM
Joined: Jul 2008
Posts: 3
S
Soopy Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Jul 2008
Posts: 3
err, i had one more questions. what if i were to create an !add command that allowed them to join a queue or list?

Re: How long users been in Channel [Re: Soopy] #202789 30/07/08 02:57 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
More detail about just what you're trying to do would be helpful, but based on what you posted
Code:
on *:text:!add:#:{
  set $+(%,nicks,.,$network,.,$chan) $addtok($+(%,nicks,.,$network,.,$chan),$nick,32)
}

When a person types !add it will add their nick to the list for that channel. If the same person types !add more than once, it won't matter as the list will only contain each nick once.