Ok I have now sorted the while loop. How ever it worked before I made some edits to if statements on adding and delling the names fron selected nicknames

Here is the code:

Code:
on ^*:OPEN:?:*: {
  if ($hget(pmusers) != $null) {
    if ($nick != $hget(pmusers, $nick)) {
      .notice $me $nick just tried to sen PM with stareting word: $1
      .notice $nick Sorry, unknown PM messages are not allowed and not received. Please ask privlidges in main chat.
      halt
    }
    else {
      msg $nick Hello, I got your message and will try to respond to you ASAP.
    }
  }
}
alias selected {
  var %counter = 1  
  var %count = $snick($chan,0)
  while (%counter <= %count) {
    var %nick = $snick($chan, %counter)
    if ($hfind(pmusers, $snick($chan, %counter) == $false) ) {
      hadd pmusers %nick %nick
      if (%count == 1 ) {
        .notice $me %nick got now PM rights.
      }
      elseif (%counter == %count) {
        .notice $me Selected group got now PM rights.
      }
      inc %counter        
    }
    elseif ($hfind(pmusers, $snick($chan, %counter) == $true)) {
      hdel -w pmusers %nick
      if (%count == 1 ) {
        .notice $me Removed PM rights from %nick.
      }
      elseif (%counter == %count) {
        .notice $me Removed PM rights from selected group.
      }
      else .notice $me Removed PM rights from selected group.
      inc %counter  
    }
  }
}
menu nicklist {
  $iif($hget(pmusers) == $null, PM rights)
  . Create access rights database {
    hmake pmusers 100
    .notice $me PM access database created.
  }
  $iif($hget(pmusers) != $null, PM rights)
  . $iif($hfind(pmusers, $snick($chan,1)) != $snick($chan,1), Give, Remove): selected 
  .-
  . Remove access database {
    hfree -w pmusers
    .notice $me PM access database destroyed.
  }
}


Whats causeing the eternal loop here?
Does it generate eternal loop because I have another skript that uses menu nicklist also ie Q/L/chanserv/nickserv controlling skript?