mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2003
Posts: 237
X
xrn0id Offline OP
Fjord artisan
OP Offline
Fjord artisan
X
Joined: Jan 2003
Posts: 237
if ($2 == on) && ($nick ishop || isop #ftpxdcc-wolf) .run command here

or:

if ($2 == on) && ($nick ishop $chan) || ($nick isop $chan) { .run commands }



;Check for Life

if (%life == $null) {
goto getlife
}
Joined: Dec 2002
Posts: 18
P
Pikka bird
Offline
Pikka bird
P
Joined: Dec 2002
Posts: 18
if ($2 == on) && ($nick ishop $chan) || ($nick isop $chan) { .run commands }

:| simple isnt it? jus' take a guess next time...

Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
All of these are correct if you mean to allow normal operator precedence (&& is higher than ||):
Code:

if (($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf)) { .run command here }
if ($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf) { .run command here }
if ($2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf) { .run command here }
if $2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf { .run command here }
 
if (($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf)) .run command here
if ($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf) .run command here
if ($2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf) .run command here
if $2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf .run command here
 
if (($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf)) $&
  .run command here
if ($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf) $&
  .run command here
if ($2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf) $&
  .run command here
if $2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf $&
  .run command here
 
if (($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf)) { 
  .run command here 
}
if ($2 == on) && ($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf) { 
  .run command here 
}
if ($2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf) { 
  .run command here 
}
if $2 == on && $nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf { 
  .run command here 
}

If you don't want ($2 == on AND $nick ishop #ftpxdcc-wolf) OR ($nick isop #ftpxdcc-wolf), then you need to at least group the two OR'd conditions together.
Code:

if (($2 == on) && (($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf))) .run command here
if ($2 == on) && (($nick ishop #ftpxdcc-wolf) || ($nick isop #ftpxdcc-wolf)) .run command here
if ($2 == on && ($nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf)) .run command here
if $2 == on && ($nick ishop #ftpxdcc-wolf || $nick isop #ftpxdcc-wolf) .run command here

NOTE: if your ".run command here" really consists of multiple commands, then { and } are required to group those commands within the condition block.

Also, you might think about switching those two ($nick is___ #ftpxdcc-wolf) conditions to a single ($nick(#ftpxdcc-wolf, $nick, oh) != $null). If you leave the parentheses around the $nick() identifier, you don't even need the != $null.
Code:

if (($2 == on) && ($nick(#ftpxdcc-wolf, $nick, oh) != $null)) .run command here
if ($2 == on) && ($nick(#ftpxdcc-wolf, $nick, oh) != $null) .run command here
if ($2 == on && $nick(#ftpxdcc-wolf, $nick, oh) != $null) .run command here
if $2 == on && $nick(#ftpxdcc-wolf, $nick, oh) != $null .run command here
 
if (($2 == on) && ($nick(#ftpxdcc-wolf, $nick, oh))) .run command here
if ($2 == on) && ($nick(#ftpxdcc-wolf, $nick, oh)) .run command here
if ($2 == on && ($nick(#ftpxdcc-wolf, $nick, oh))) .run command here
if $2 == on && ($nick(#ftpxdcc-wolf, $nick, oh)) .run command here

How you choose to format your script is largely a matter of personal choice. Some of those configurations are faster than others, some conditional expressions require parenthesis or braces to delineate when the conditional expression has stopped (such as isin or iswm). If you're not interested in optimizing your script for speed, then pick the one that makes the most "sense" to you or the one you happen to like the looks of the best. Try to stick with the same format through your script, wherever you can. You'll get used to seeing the same constructions which will make it easier for you to grasp the sense of what a section of script is supposed to be doing.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
Quote:
All of these are correct if you mean to allow normal operator precedence (&& is higher than ||):


Too bad operator precedence doesn't work in mirc frown The expressions you wrote do what they're supposed to, but not because && precedes ||; only because && is to the left of ||: /if statements in mirc are just evaluated from left to right (unless otherwise specified with grouping parentheses) and the precedence of && over || is ignored.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard