mIRC Homepage
Posted By: Vinniej !peak script? - 01/07/05 09:09 PM
Hi,

I'm looking to a good working !peak script wich one is easily to start.

Hope someone can help me smile
Posted By: DaveC Re: !peak script? - 01/07/05 10:56 PM
alt-r/file/new/ then add this line

on *:text:!peak*:*:{ echo -a Peak Script Triggered, Amazing Eh! }
Posted By: Riamus2 Re: !peak script? - 05/07/05 01:45 PM
Code:
on *:join:#yourchan: {
  if ($nick(#,0) >= $+(%,peak.,$chan)) {
    set $+(%,peak.,$chan) $nick(#,0) $ctime
  }
}

on *:text:!peak:#yourchan: {
  msg $chan On $date($gettok($+(%,peak.,$chan),2,32),mmm dd yyyy) $+ , there were $gettok($+(%,peak.,$chan),1,32) users in $chan $+ !
}


Note that you can add in the time as well as the date by just editing the output line's $date statement. That's why I used $ctime when setting the variable.

This will work for multiple channels as long as the channel names are different (i.e. not the same name on two different networks).
Posted By: OrionsBelt Re: !peak script? - 30/06/07 12:33 PM
I do like this script, it's pretty simple and basic set up.
The only thing I dislike it the way it stores the info... By setting it as variables.
In my opinion you should avoid having long lists of variables in your variable window.

How would you make a version using hash tables?
Posted By: Riamus2 Re: !peak script? - 03/07/07 01:02 AM
Here's a hash version.

Code:
on *:join:#: {
  if (!$hget(PeakStats)) {
    hmake PeakStats 10
    if ($isfile($scriptdir\PeakStats.hsh)) { hload PeakStats $scriptdir\PeakStats.hsh }
  }
  if ($nick(#,0) >= $hget(PeakStats,$chan)) {
    hadd PeakStats $chan $nick(#,0) $ctime
    hsave PeakStats $scriptdir\PeakStats.hsh
  }
}

on *:text:!peak:#: {
  msg $chan On $date($gettok($hget(PeakStats,$chan),2,32),mmm dd yyyy) $+ , there were $gettok($hget(PeakStats,$chan),1,32) users in $chan $+ !
}

Posted By: OrionsBelt Re: !peak script? - 03/07/07 05:13 AM
laugh

Aha, there we go.
Gonna test it tonight, Thanks Riamus!
Posted By: OrionsBelt Re: !peak script? - 03/07/07 05:56 PM
Uhm, you missed one section. Thats in case the channel doesn't exist yet.
But I could figure that part myself. Here is the slightly updated version:

Code:
on *:join:#:{
  if (!$hget(PeakStats)) {
    hmake PeakStats 10
    if ($isfile($scriptdir\PeakStats.hsh)) { hload PeakStats $scriptdir\PeakStats.hsh }
  }
  if ($nick(#,0) >= $hget(PeakStats,$chan)) {
    hadd PeakStats $chan $nick(#,0) $ctime
    hsave PeakStats $scriptdir\PeakStats.hsh
  }
  if (!$hget(PeakStats,$chan)) {
    hadd PeakStats $chan $nick(#,0) $ctime
    hsave PeakStats $scriptdir\PeakStats.hsh
  }
}

on *:text:!peak:#:{
  msg $chan On $date($gettok($hget(PeakStats,$chan),2,32),mmm dd yyyy) $+ , there were $gettok($hget(PeakStats,$chan),1,32) users in $chan $+ !
}
Posted By: Riamus2 Re: !peak script? - 04/07/07 12:15 AM
Here:

Code:
on *:join:#:{
  if (!$hget(PeakStats)) {
    hmake PeakStats 10
    if ($isfile($scriptdir\PeakStats.hsh)) { hload PeakStats $scriptdir\PeakStats.hsh }
  }
  if ($nick(#,0) >= $hget(PeakStats,$chan) || !$hget(PeakStats,$chan)) {
    hadd PeakStats $chan $nick(#,0) $ctime
    hsave PeakStats $scriptdir\PeakStats.hsh
  }
}

on *:text:!peak:#:{
  msg $chan On $date($gettok($hget(PeakStats,$chan),2,32),mmm dd yyyy) $+ , there were $gettok($hget(PeakStats,$chan),1,32) users in $chan $+ !
}
Posted By: LostShadow Re: !peak script? - 07/07/07 05:53 AM
Originally Posted By: Riamus2
Code:
on *:join:#yourchan: {
  if ($nick(#,0) >= $+(%,peak.,$chan)) {
    set $+(%,peak.,$chan) $nick(#,0) $ctime
  }
}

on *:text:!peak:#yourchan: {
  msg $chan On $date($gettok($+(%,peak.,$chan),2,32),mmm dd yyyy) $+ , there were $gettok($+(%,peak.,$chan),1,32) users in $chan $+ !
}


Note that you can add in the time as well as the date by just editing the output line's $date statement. That's why I used $ctime when setting the variable.

This will work for multiple channels as long as the channel names are different (i.e. not the same name on two different networks).


$date()?

I only see $date.

Anyways..

On , there were %peak.#channel.Network users in #channel!

Not working..

On join event:

Code:
  if ($nick(#,0) >= $+(%,peak.,$chan,.,$network)) {    
    set $+(%,peak.,$chan,.,$network) $nick(#,0) $ctime
    /echo $chan On $asctime($gettok($+(%,peak.,$chan,.,$network),2,32),mmm dd yyyy) $+ , there were $gettok($+(%,peak.,$chan,.,$network),1,32) users in $chan $+ !
  }
Posted By: Horstl Re: !peak script? - 07/07/07 06:19 AM
In the on text event, it's missing an evaluation of the variable to get not the variable's name, but it's value:
$($+(%,peak.,$chan),2)

Code:
on *:text:!peak:#yourchan,#anotherchan,...: {
  var %val = $($+(%,peak.,$chan),2)
  msg $chan On $date($gettok(%val,2,32),mmm dd yyyy) $+ , there were $gettok(%val,1,32) users in $chan $+ !
}


To format the output of the date/time, check:
/help $asctime

e.g: $asctime($gettok(%val,2,32),mmmm dd yyyy - hh:nn:ss tt) will return something like "July 07 2007 - 08:21:28 am"
... $date can be used as well, sure smile

Edit: And I wonder why you don't use Riamus2's nice hash based code...
Posted By: Riamus2 Re: !peak script? - 07/07/07 03:18 PM
Yes, there was a missing evaluation in the original code. Just use the latest version. As for $date(), that works just fine.
Posted By: LostShadow Re: !peak script? - 07/07/07 04:38 PM
Wait a minute, topics can be bumped now?

Truth is, I used both.

You'll noticed I added a ,.,$network after $chan.

In other words, I'm in several #mIRC or #lobby.

So the hash table one I kept for all channels undistinguished by network.
Posted By: LostShadow Re: !peak script? - 07/07/07 04:42 PM
Originally Posted By: Horstl
In the on text event, it's missing an evaluation of the variable to get not the variable's name, but it's value:
$($+(%,peak.,$chan),2)

Code:
on *:text:!peak:#yourchan,#anotherchan,...: {
  var %val = $($+(%,peak.,$chan),2)
  msg $chan On $date($gettok(%val,2,32),mmm dd yyyy) $+ , there were $gettok(%val,1,32) users in $chan $+ !
}


To format the output of the date/time, check:
/help $asctime


Uh, any reason why $nick(#,0) or $ctime isn't included in your code?
Posted By: Horstl Re: !peak script? - 07/07/07 06:12 PM
I wanted to point to the missing evaluation, so I posted the on text event as illustration, of course you need the on join event.

The on text is to msg the max peak, it's read only and returning absolute values (the peak record)... But you can calculate relative values - using read value and actual values $nick(#,0) / $ctime.

Here's an example, I also added that network val you want to use:
Code:
on *:join:#chan,#otherchan,...: {
  if ($nick(#,0) > $($+(%,peak.,$chan,.,$network),2)) {
    set $+(%,peak.,$chan,.,$network) $nick(#,0) $ctime
  }
}

on *:text:!peak:#chan,#otherchan,...: {
  var %val = $($+(%,peak.,$chan,.,$network),2)
  if (%val) {
    msg $chan On $+( $date($gettok(%val,2,32),mmm dd yyyy) $&
    $chr(40), $duration($calc($ctime - $gettok(%val,2,32)),2) ago, $chr(41)) $&
     there were $gettok(%val,1,32) users $&
    (thats $round($calc(100 - $nick($chan,0) / $gettok(%val,1,32) * 100),0) $+ % more than now) $&
    in $chan $+ !
  }
}

This will return something like:
On Jul 07 2007 (12mins ago) there were 75 users (thats 3% more than now) in #test!

Anyway, I'd prefer the code with hash tables...
Posted By: Riamus2 Re: !peak script? - 07/07/07 06:35 PM
Originally Posted By: LostShadow
Wait a minute, topics can be bumped now?

No.

Originally Posted By: LostShadow
You'll noticed I added a ,.,$network after $chan.

In other words, I'm in several #mIRC or #lobby.

So the hash table one I kept for all channels undistinguished by network.


Here's an update for multiple networks.
Code:
on *:join:#:{
  if (!$hget(PeakStats)) {
    hmake PeakStats 100
    if ($isfile($scriptdir\PeakStats.hsh)) { hload PeakStats $scriptdir\PeakStats.hsh }
  }
  var %chan.net = $+( $chan ,., $network)
  if ($nick(#,0) >= $hget(PeakStats,%chan.net) || !$hget(PeakStats,%chan.net)) {
    hadd PeakStats %chan.net $nick(#,0) $ctime
    hsave PeakStats $scriptdir\PeakStats.hsh
  }
}

on *:text:!peak:#:{
  var %peak.stat = $hget(PeakStats,$+( $chan ,., $network )
  msg $chan On $date($gettok(%peak.stat,2,32),mmm dd yyyy) $+ , there were $gettok(%peak.stat,1,32) users in $chan $+ !
}
Posted By: LostShadow Re: !peak script? - 08/07/07 07:29 AM
Originally Posted By: Horstl
Code:
on *:join:#chan,#otherchan,...: {
  if ($nick(#,0) > $($+(%,peak.,$chan,.,$network),2)) {
    set $+(%,peak.,$chan,.,$network) $nick(#,0) $ctime
  }
}


No that didn't work.

Second line works using:

if ($nick(#,0) >= $+(%,peak.,$chan.,$network)) {

Else it won't create the variable if it doesn't exist.

Edit: Well, scratch that too, it'll say there's a new record when there isn't one..

So I've tried using..

Code:
on *:join:#: {
  if ($+(%,peak.,$chan,.,$network) == $null) { /set $+(%,peak.,$chan,.,$network) $nick(#,0) $ctime }
  if ($nick(#,0) >= $+(%,peak.,$chan,.,$network)) {    
    /set $+(%,peak.,$chan,.,$network) $nick(#,0) $ctime
    var %value = $($+(%,peak.,$chan,.,$network),2)
    if (%value) {
      /echo $chan $+($date($gettok(%value,2,32),mmmm dd yyyy)), ( $+ $duration($calc($ctime - $gettok(%value,2,32)),2) ago), there is a channel record of $gettok(%value,1,32) users!
    }
  }
}


No luck. Ever channel join is a record...
Posted By: deegee Re: !peak script? - 08/07/07 09:11 AM
Code:
on *:join:#chan,#otherchan:{
  if ($nick(#,0) > $($+(%,peak.,#,.,$network),2)) || (!$($+(%,peak.,#,.,$network),2)) {
    set $+(%,peak.,#,.,$network) $nick(#,0) $ctime
    echo # There is now a new channel record of $nick(#,0) users!
  }
}
on *:text:!peak:#chan,#otherchan:{
  tokenize 32 $($+(%,peak.,#,.,$network),2)
  if ($0) {
    msg # On $date($2,mmmm dd yyyy) ( $+ $duration($calc($ctime - $2),2) ago $+ ) there were $1 $&
      users (thats $round($calc(100 - $nick(#,0) / $1 * 100),0) $+ % more than now) in # $+ !
  }
}
Posted By: Riamus2 Re: !peak script? - 08/07/07 12:54 PM
Why don't you just use the updated hash table version? You're going to have a LOT of variables if you don't.
Posted By: Horstl Re: !peak script? - 08/07/07 01:44 PM
Originally Posted By: LostShadow
Code:
on *:join:#chan,#otherchan,...: {
  if ($nick(#,0) > $($+(%,peak.,$chan,.,$network),2)) {
    set $+(%,peak.,$chan,.,$network) $nick(#,0) $ctime
  }
}


No that didn't work.
You're right, my mistake. It could be:
Code:
if ($nick(#,0) > $iif($($+(%,peak.,$chan,.,$network),2),$gettok($v1,1,32),0)) {
But $me still signs:
Originally Posted By: Riamus2
Why don't you just use the updated hash table version? You're going to have a LOT of variables if you don't.
smile
Posted By: OrionsBelt Re: !peak script? - 08/07/07 05:49 PM
var %peak.stat = $hget(PeakStats,$+( $chan ,., $network ))

Bracket mismatch frown
Posted By: LostShadow Re: !peak script? - 08/07/07 06:37 PM
Okay thanks all for your support.

Originally Posted By: Riamus2
Why don't you just use the updated hash table version? You're going to have a LOT of variables if you don't.


Oh I'm using them both. Although, I wouldn't say there's a lot of variables. You're only having as many variables as channels you join.
Posted By: Riamus2 Re: !peak script? - 08/07/07 06:38 PM
Those get me all the time smile

Code:
on *:join:#:{
  if (!$hget(PeakStats)) {
    hmake PeakStats 100
    if ($isfile($scriptdir\PeakStats.hsh)) { hload PeakStats $scriptdir\PeakStats.hsh }
  }
  var %chan.net = $+( $chan ,., $network)
  if ($nick(#,0) >= $hget(PeakStats,%chan.net) || !$hget(PeakStats,%chan.net)) {
    hadd PeakStats %chan.net $nick(#,0) $ctime
    hsave PeakStats $scriptdir\PeakStats.hsh
  }
}

on *:text:!peak:#:{
  var %peak.stat = $hget(PeakStats,$+( $chan ,., $network ))
  msg $chan On $date($gettok(%peak.stat,2,32),mmm dd yyyy) $+ , there were $gettok(%peak.stat,1,32) users in $chan $+ !
}
Posted By: OrionsBelt Re: !peak script? - 11/07/07 09:42 PM
Uhm, I still have some problems with this script.

Shouldnt this line:
if ($nick(#,0) >= $hget(PeakStats,%chan.net) || !$hget(PeakStats,%chan.net)) {

Be:
if ($nick(#,0) >= $gettok($hget(PeakStats,%chan.net),1,32) || !$hget(PeakStats,%chan.net)) {

confused
Posted By: Horstl Re: !peak script? - 11/07/07 10:06 PM
That would be more exact.
But if comparison is generous:
Code:
//var %x = 5 test | if (3 < %x) { echo -a $v1 < $v2 }

or
Code:
//var %x = 6apples | if (3 < %x) { echo -a $v1 < $v2 }
Posted By: Riamus2 Re: !peak script? - 12/07/07 12:14 AM
What problems?

Yes, you can change it to that. It should work both ways, but you are right, that it will be more correct with checking the token.
Posted By: OrionsBelt Re: !peak script? - 12/07/07 05:35 AM
=21:35:15= * Nickname1 (address1) has joined #peak-chan
=21:35:15= <@Bot> New channel peak for channel: #peak-chan
=21:35:15= <@Bot> Last peak was on 10 July 2007, there were 41 users!

=21:35:19= * Nickname2 (address2) has joined #peak-chan
=21:35:19= <@Bot> New channel peak for channel: #peak-chan
=21:35:19= <@Bot> Last peak was on 11 July 2007, there were 5 users!

On the 10th of July, we managed to set a peak of 41 users. The next day, we started with 3 users.
When the 4th joined, it showed the peak from yesterday, and when the 5th joined it had overwritten the old peak!
Posted By: Riamus2 Re: !peak script? - 12/07/07 03:27 PM
Sounds like it's either not saving or not loading your table. Check the folder where you have the script stored and see if you see a PeakStats.hsh file there.
© mIRC Discussion Forums