mIRC Home    About    Download    Register    News    Help

Print Thread
#9775 05/02/03 04:59 AM
Joined: Dec 2002
Posts: 51
D
Dingo Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2002
Posts: 51
i've been going thrugh my optalk script to rescript it. its using goto's and returns and all that, and i'm trying to convert it to using while loops... i've had success with messaging ops, voices, and ops/voices, but now i'm trying to message those people who are listed in my userlist as ops, but are not oped on the channel...

here's the code of the original script:

Code:
/co {
  set %cnopnr 0
  :check
  inc %cnopnr 1
  if $nopnick($chan,%cnopnr) == $null goto done
  if $level($address($nopnick($chan,%cnopnr),3)) == 10 goto found
  else goto check
  :found
  echo 10 -a 1 $nopnick($chan,%cnopnr) 12,8 Op's notice 12,15 $1-
  .notice   $nopnick($chan,%cnopnr) 
12,8 sub Op's notice 12,15 $1-
  goto check
  :done
  echo 10 -a 12,8---------Sending sub op's ompleted----------
  unset %cnopnr
  :end
}



and here is the new code I have. it does work, but it sends to the oped ops and not the deoped nicks even though i have !isop there

Code:
Alias CO {
  set %CO $nick(#,0)
  set %COtold 1
  while ( %COtold < %CO ) {
    set %COguy $nick(#,%COtold)
    if ( $level($address(%COguy,1)) == %OL ) && ( $COguy !isop $chan ) {
      .notice %COguy 0,2 %myname 15<=>0 To Sub-Ops 15=]2,0 $1- 15,2[=
      Echo -a 0,2 Sent 15<=>0 To %COguy 15=]2,0 $1- 15,2[=
      inc %COtold 1
    }
  }
  unset %CO
  unset %COtold
  Unset %COguy
}

#9776 05/02/03 05:17 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
You wrote ( $COguy !isop $chan ). %COguy isn't an identifier, it's a variable smile

Here's somewhat shorter version of your code:
Code:

alias CO {
  var %total = $nick(#,0), %counter = 1
  while (%counter <= %total) { 
    var %nick = $nick(#,%counter)    
    if ($level($address(%nick,5)) == %OL) && (%nick !isop #) {   
      .notice %nick 0,2 %myname 15<=>0 To Sub-Ops 15=]2,0 $1- 15,2[=    
      Echo -a 0,2 Sent 15<=>0 To %nick 15=]2,0 $1- 15,2[=   
    } 
    inc %counter
  } 
}

- Used local variables instead of global ones
- Used address type of 5 (instead of 1), that returns full address.
- Moved /inc outside of the if statement.
- Also, /unset can unset several variables in one command, eg: /unset %1 %2. Anyway, since the code above uses local variables, it's not needed here.
- Should %myname represent your nick? if so, you can use $me.

#9777 05/02/03 05:28 AM
Joined: Dec 2002
Posts: 51
D
Dingo Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2002
Posts: 51
heh thanks for pointing that out. i had a problem with it getting stuck in the loop... inc %COtold wasn't working smile so i moved it down to the end of the wile loop smile

then i view the post again and omg - i didn't even see 1/4 of what you posted smirk

thanks smile

Last edited by Dingo; 05/02/03 05:30 AM.
#9778 05/02/03 05:32 AM
Joined: Dec 2002
Posts: 51
D
Dingo Offline OP
Babel fish
OP Offline
Babel fish
D
Joined: Dec 2002
Posts: 51
%myname is a variable which contains my real name... it was there for the original script so i left it there

#9779 05/02/03 05:52 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
you're welcome smile


Link Copied to Clipboard