mIRC Homepage
Posted By: Hazemaker Whats wrong in my Peak script? - 22/12/05 11:06 PM
My peak script actually works. There is only 1 problem. When bot joins a channel and it have no variable peak for current channel it should auto set a variable with peak, but it doesnt :S whats wrong in the script?

on *:join:#: {

if (!%peak. [ $+ [ $chan ] ]) {
set %peak. $+ $chan 0
}
if ($nick($chan,0) > %peak. [ $+ [ $chan ] ]) {
set %peak. $+ $chan $ifmatch
}
}
on *:text:.peak:#: {

if (!%peakspam. [ $+ [ $chan ] ]) {
set -u10 %peakspam. $+ $chan 1
msg $chan User peak for $chan is: %peak. [ $+ [ $chan ] ]
}
}
Posted By: draven24 Re: Whats wrong in my Peak script? - 22/12/05 11:31 PM
Code:
set %peak. $+ $chan 0


should be:

Code:
set %peak. [ $+ [ $chan ] ] 0


EDIT: same goes for the other /set's
Posted By: FiberOPtics Re: Whats wrong in my Peak script? - 22/12/05 11:56 PM
No it shouldn't.

[ ] are never required when setting a variable, only in certain cases with /unset, and when looking up the value of a dynamic variable (that is if you don't use $eval instead).
Posted By: draven24 Re: Whats wrong in my Peak script? - 23/12/05 12:06 AM
Oh, i knew you had to use the brackets when getting the value of the variable, i just assumed you needed them to set it aswell. My bad.

Learn something new every day huh?
Posted By: FiberOPtics Re: Whats wrong in my Peak script? - 23/12/05 12:31 AM
Code:
on *:text:.peak:#:{
  var %net = $iif($network,$network,$server)
  var %flood = $+(%,peakflood,%net,#)
  if ($(,%flood)) return
  inc -z $(%flood) 5
  var %peak = $+(%,peak,%net,#)
  if (!$(,%peak)) set $(%peak) $nick(#,0)
  msg # User peak for # is: $(,%peak)
}
 [color:red]  [/color] 
on !*:join:#:{
  var %peak = $+(%,peak,$iif($network,$network,$server),#)
  if ($nick(#,0) > $calc($(,%peak))) set $(%peak) $ifmatch
}

For those wondering, the $calc is there so you can use this code without having to rejoin all channels you are currently in, because if (5 > $null) is no valid if comparision, but if (5 > $calc($null)) is, since $calc($null) returns 0.

I've added a simplistic flood protection so that people can only use the .peak command once per 5 seconds on a certain channel from a certain network.

The script is network specific, so the peak for channel #mirc on network DALnet, will be different from #mirc on network Undernet. If $network isn't filled, it uses the $server name as reference.
Posted By: chili_beta Re: Whats wrong in my Peak script? - 01/07/07 08:39 PM
and to also show the date?
© mIRC Discussion Forums