mIRC Home    About    Download    Register    News    Help

Page 1 of 2 1 2 >
Topic Options
#124070 - 01/07/05 10:09 PM !peak script?
Vinniej Offline
Babel fish

Registered: 15/04/05
Posts: 64
Loc: Amsterdam, The Netherlands
Hi,

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

Hope someone can help me smile

Top
#124071 - 01/07/05 11:56 PM Re: !peak script?
DaveC Offline
Planetary brain

Registered: 26/09/03
Posts: 4230
alt-r/file/new/ then add this line

on *:text:!peak*:*:{ echo -a Peak Script Triggered, Amazing Eh! }

Top
#124072 - 05/07/05 02:45 PM Re: !peak script?
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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).
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#179925 - 30/06/07 01:33 PM Re: !peak script? [Re: Riamus2]
OrionsBelt Offline
Fjord artisan

Registered: 25/04/06
Posts: 464
Loc: Amsterdam, NL
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?

Top
#180055 - 03/07/07 02:02 AM Re: !peak script? [Re: OrionsBelt]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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 $+ !
}

_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#180065 - 03/07/07 06:13 AM Re: !peak script? [Re: Riamus2]
OrionsBelt Offline
Fjord artisan

Registered: 25/04/06
Posts: 464
Loc: Amsterdam, NL
laugh

Aha, there we go.
Gonna test it tonight, Thanks Riamus!

Top
#180088 - 03/07/07 06:56 PM Re: !peak script? [Re: Riamus2]
OrionsBelt Offline
Fjord artisan

Registered: 25/04/06
Posts: 464
Loc: Amsterdam, NL
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 $+ !
}

Top
#180107 - 04/07/07 01:15 AM Re: !peak script? [Re: OrionsBelt]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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 $+ !
}
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#180287 - 07/07/07 06:53 AM Re: !peak script? [Re: Riamus2]
LostShadow Offline
Fjord artisan

Registered: 12/01/04
Posts: 509
Loc: Chicago, Illinois, U.S.A.
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 $+ !
  }


Edited by LostShadow (07/07/07 06:54 AM)

Top
#180288 - 07/07/07 07:19 AM Re: !peak script? [Re: Vinniej]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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...


Edited by Horstl (07/07/07 07:50 AM)

Top
#180306 - 07/07/07 04:18 PM Re: !peak script? [Re: LostShadow]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Yes, there was a missing evaluation in the original code. Just use the latest version. As for $date(), that works just fine.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#180316 - 07/07/07 05:38 PM Re: !peak script? [Re: Riamus2]
LostShadow Offline
Fjord artisan

Registered: 12/01/04
Posts: 509
Loc: Chicago, Illinois, U.S.A.
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.

Top
#180317 - 07/07/07 05:42 PM Re: !peak script? [Re: Horstl]
LostShadow Offline
Fjord artisan

Registered: 12/01/04
Posts: 509
Loc: Chicago, Illinois, U.S.A.
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?

Top
#180324 - 07/07/07 07:12 PM Re: !peak script? [Re: Vinniej]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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...

Top
#180327 - 07/07/07 07:35 PM Re: !peak script? [Re: LostShadow]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
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 $+ !
}
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#180360 - 08/07/07 08:29 AM Re: !peak script? [Re: Horstl]
LostShadow Offline
Fjord artisan

Registered: 12/01/04
Posts: 509
Loc: Chicago, Illinois, U.S.A.
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...


Edited by LostShadow (08/07/07 08:53 AM)

Top
#180361 - 08/07/07 10:11 AM Re: !peak script? [Re: LostShadow]
deegee Offline
Fjord artisan

Registered: 16/06/06
Posts: 508
Loc: Storage
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 # $+ !
  }
}

Top
#180367 - 08/07/07 01:54 PM Re: !peak script? [Re: LostShadow]
Riamus2 Offline
Planetary brain

Registered: 13/10/04
Posts: 8327
Loc: MA, USA
Why don't you just use the updated hash table version? You're going to have a LOT of variables if you don't.
_________________________
Invision Support
#Invision on irc.irchighway.net

Top
#180370 - 08/07/07 02:44 PM Re: !peak script? [Re: LostShadow]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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

Top
#180385 - 08/07/07 06:49 PM Re: !peak script? [Re: Riamus2]
OrionsBelt Offline
Fjord artisan

Registered: 25/04/06
Posts: 464
Loc: Amsterdam, NL
var %peak.stat = $hget(PeakStats,$+( $chan ,., $network ))

Bracket mismatch frown

Top
Page 1 of 2 1 2 >