mIRC Homepage
Posted By: RusselB Script causing loop - 22/03/05 02:29 AM
Code:
 on *:text:!update:#:{ 
  .notice $nick checking for ops in the room and adding them to the user list 
  var %b = 1 
  while $nick(#,0,o) >= %b {
    //echo # %b $nick(#,%b,o)
    .auser 10 $nick(#,%b,o)
    inc %b
  } 
  .notice $nick checking for ops in the userlist that are not in the room and removing them from the list 
  var %b = 1 
  while $ulist(*,10,0) >= %b {
    if ($ulist(*,10,%b) !ison #) {
      //echo # %b $nick(#,%b,o)
      .ruser $v1
      inc %b
    }
  }
  .notice $nick voicing those in the room that qualify but aren't voiced 
  var %b = $nick(#,0,a,v) 
  while %b > 0 {
    if $regex(uc,$nick(#,%b,a,v),/^[^[:alpha:]]*?[A-Z]/) {
      //echo # %b $nick(#,%b,a,v)
      mode # +v $nick(#,%b,a,v)
    }
    dec %b
  } 
  .notice $nick checking for people that are in the players list but not in the room and removing them 
  var %b = 1
  while $numtok(%play.list,44) >= %c {
    if ($gettok(%play.list,%b,44) !ison #) {
      set %play.list $remtok(%play.list,$v1,1,44)
      inc %b
    }
  } 
  .notice $nick checking for autoplay of all in the room and if on adding them to the players list 
  var %b = $nick(#,0)
  while %b > 0 {
    if ($read($mknickfn($nick(#,%c)),s,autoplay) == on) {
      set %play.list $addtok(%play.list,$nick(#,%b),44)
    }
    dec %b
  } 
  .notice $nick Update complete
  if %play.list describe # Current Players are %play.list
}
 


The above script was working fine...but recently has started making an unending loop...
The loop appears to be coming in during the, for lack of a better phrase, second section
Posted By: tidy_trax Re: Script causing loop - 22/03/05 02:54 AM
Two sections of your script can cause infinite loops.

Code:
    if ($ulist(*,10,%b) !ison #) {
      //echo # %b $nick(#,%b,o)
      .ruser $v1
      inc %b
    }


You should inc %b outside of the if statement.

Code:
    if ($gettok(%play.list,%b,44) !ison #) {
      set %play.list $remtok(%play.list,$v1,1,44)
      inc %b
    }


Same for this.
Posted By: gemeau50 Re: Script causing loop - 22/03/05 02:55 AM
.notice $nick checking for people that are in the players list but not in the room and removing them
var %b = 1
while $numtok(%play.list,44) >= %c {
if ($gettok(%play.list,%b,44) !ison #) {
set %play.list $remtok(%play.list,$v1,1,44)
inc %b
}
}
Posted By: RusselB Re: Script causing loop - 22/03/05 02:59 AM
That was the problem...thanks
© mIRC Discussion Forums