mIRC Homepage

How long users been in Channel

Posted By: Soopy

How long users been in Channel - 29/07/08 07:27 AM

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.
Posted By: RusselB

Re: How long users been in Channel - 29/07/08 08:02 AM

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.
Posted By: Soopy

Re: How long users been in Channel - 29/07/08 08:12 AM

thanks RusselB. i really appreciate it.
Posted By: Soopy

Re: How long users been in Channel - 29/07/08 10:27 AM

err, i had one more questions. what if i were to create an !add command that allowed them to join a queue or list?
Posted By: RusselB

Re: How long users been in Channel - 30/07/08 02:57 AM

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.

© 2021 mIRC Discussion Forums