Ok sorted the loop now and working fantastic. Anymore is to do some kind of OP checking system that checks if pm sender is OP in same channel than I am thus automatically grants pm access to Operators.

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)
  var %first = $snick($chan, 1)
  var %boolean = $hfind(pmusers, %first)

  while (%counter <= %count) { 
    var %nick = $snick($chan, %counter)

    if (%boolean != %first) {
      hadd pmusers %nick %nick
      if (%count == 1 ) {
        .notice $me %nick added to PM access database.
      }
      if (%counter == %count && %count > 1) {
        .notice $me Selected group added to PM access database.
      }        
    }
    if (%boolean == %first ) {      
      hdel -w pmusers %nick
      if (%count == 1) {
        .notice $me Removed %nick from PM access database.
      }
      if (%counter == %count && %count > 1) {
        .notice $me Removed selected group from PM access database.
      }
    }
    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.
  }
}

Last edited by Jeroi; 17/04/11 06:14 PM.