|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
Not long ago I asked about a script to use $iif in the mouse events option of mirc's options' dialog (and it's worked brilliantly so far) and now I have another. The folowing code keeps giving me the error of * Invalid format: $iif. The code I have is:
$iif(($address($me,9) isaop #) || ($me isop #) || ($me ishop #) && ($$1 !ishop #) && ($$1 !isop #)),ignore -wdiknpt $address($$1,9) | ban -k $$1 2 $read(kix.txt))
What I want to do (if this code doesnt explain it) is:
if Im on the aop list (mask 9) OR a channel op OR a channel halfop AND the user is NOT a halfop AND not an op, perform the commands ignore -wdiknpt $address($$1,9) | ban -k $$1 2 $read(kix.txt)
I just can't see what Im doing wrong here. Yes, I know I could alias it, but I'd really like it to be done this way if possible
Those who fail history are doomed to repeat it
|
|
|
|
Joined: Dec 2002
Posts: 3,547
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 3,547 |
Is it that you can't use pipes? Or can you?
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Give this a try $iif((($address($me,9) isaop $chan) || ($me isop $chan) || ($me ishop $chan)) && (($$1 !isop $chan) || ($$1 !ishop $chan)), ignore -wdiknpt $address($$1,9) | .ban -k $$1 2 $read(kix.txt)) Basically what I've done is separated your comparisons into two groups...the first group checks your status, the 2nd group checks the status of the nick in $$1...Note the $$ means that if there's nothing in that location, nothing will be done
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
You can't use pipes in $iif and expect it to work as a command separator. I mentioned in my post on your old topic, this is what if statements are for. But if you insist on using $iif then go for DaveC's example:
$$iif(($nick(#,$me,oh) || $address($me,9) isaop #) && !$nick(#,$$1,oh),ignore -wdiknpt $1 9) | ban -k $1 2 $read(kix.txt)
The $$iif will halt if no value is returned so it will continue on to the ban only if the conditions were satisfied. Also, you can't ban someone if you're on mIRC's aop list but not oped/halfoped so you might want to add a check for that. As I said, if statements are suitable here
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
/help $iif $iif(C,T,F) Well what do you expect to happen if you just go //echo -a $iif($true) ???? <snicker snicker> $iif(($address($me,9) isaop #) || ($me isop #) || ($me ishop #) && ($$1 !ishop #) && ($$1 !isop #)),ignore -wdiknpt $address($$1,9) | ban -k $$1 2 $read(kix.txt)) Oh dear oh dear, whats that ) doing in there. The Other problem is of course already been said that u cant use a command seperator there to place two commands anyway. Why not just use an IF ? IF (($address($me,9) isaop #) || ($me isop #) || ($me ishop #) && ($$1 !ishop #) && ($1 !isop #)) { ignore -wdiknpt $address($$1,9) | ban -k $1 2 $read(kix.txt) }
|
|
|
|
Joined: Apr 2003
Posts: 701
Hoopy frood
|
Hoopy frood
Joined: Apr 2003
Posts: 701 |
heh, didn't know that $$ stuff halts the entire script, I believed it just skipped that line... Just if you do not want to halt the script, you can use my favorite identifier: $v1 !$v1 as test works too if you want an extra else, just note that !$v1 where $v1 == $null will set $v1 to $true $iif(($nick(#,$me,oh) || $address($me,9) isaop #) && !$nick(#,$$1,oh),ignore -wdiknpt $1 9) | $iif($v1,ban -k $1 2 $read(kix.txt)
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
As Sigh pointed out, $iif() is suitable when you want to use a certain value in a command, based on a condition. So, $iif() is suitable in cases like: //echo -a I'm using a $iif($version < 6.16,old,new) version of mirc
You can notice two things here: 1. $iif() returns a value, "old" or "new", based on a condition ($version check). 2. This value is used inside a command (/echo in this case). It is NOT a command itself.
Compare the above line with this one: //if ($version < 6.16) { echo -a I'm using a new version of mirc } | else echo -a I'm using an old version of mirc
The former is definitely shorter. THAT is where $iif() is useful.
In your case though, you aren't using $iif() to get a value (to be used in a command), you're using it to execute a command and, even worse, multiple commands. This seems plain wrong, it's the wrong tool for the job. The right tool is of course, /if: THIS is what you use to execute commands based on a condition. In your case specifically:
//if (($me isop #) && (...) && (...)) { ignore -wdiknpt $address($$1,9) | ban -k $$1 2 $read(kix.txt)) }
Just give this a try in mouse events section, you'll see it works fine.
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Dec 2002
Posts: 1,541
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2002
Posts: 1,541 |
ok, I think I understand what you're saying and I'll have to give your code a try. Thanks to everybody for your replies. I think the reason I went with $iif originally was because I couldnt make and if statement work (I mean no errors or messages at all even if I swapped out an ECHO for what was there) and so thought about $iif. In the case of my other post, I wanted it to work conditionally so that if 1 then /1 and if 2, then /2 and since I was having /if issues, I wanted to use $iif. I guess it's simply me misinterpreting what it's to be used for (which has happened before).
Those who fail history are doomed to repeat it
|
|
|
|
|