mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#124070 01/07/05 09:09 PM
Joined: Apr 2005
Posts: 64
V
Vinniej Offline OP
Babel fish
OP Offline
Babel fish
V
Joined: Apr 2005
Posts: 64
Hi,

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

Hope someone can help me smile

#124071 01/07/05 10:56 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
alt-r/file/new/ then add this line

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

#124072 05/07/05 01:45 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Riamus2 #179925 30/06/07 12:33 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Riamus2 #180065 03/07/07 05:13 AM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
laugh

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

Riamus2 #180088 03/07/07 05:56 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
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 $+ !
}

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Riamus2 #180287 07/07/07 05:53 AM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
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 $+ !
  }

Last edited by LostShadow; 07/07/07 05:54 AM.
Vinniej #180288 07/07/07 06:19 AM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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...

Last edited by Horstl; 07/07/07 06:50 AM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Riamus2 #180316 07/07/07 04:38 PM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
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.

Horstl #180317 07/07/07 04:42 PM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
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?

Vinniej #180324 07/07/07 06:12 PM
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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...

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Horstl #180360 08/07/07 07:29 AM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
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...

Last edited by LostShadow; 08/07/07 07:53 AM.
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
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 # $+ !
  }
}

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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

Riamus2 #180385 08/07/07 05:49 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
var %peak.stat = $hget(PeakStats,$+( $chan ,., $network ))

Bracket mismatch frown

Page 1 of 2 1 2

Link Copied to Clipboard