mIRC Homepage
Posted By: KoRn18 $iif - 28/08/03 07:09 PM
can i use /iif or maybe even $iif inside of on text statments, replacing /if like this:

on @15:text:!* :#: {
$iif($1 == !die,part $chan,notice $nick Nope, No Access.)
}

(for my bot) im wondering because before i tear the crap out of my codes, i want to know if it works or not..
Posted By: Raccoon Re: $iif - 28/08/03 07:21 PM
$iif is mostly used for minor variances in a string, and not the best choice for your situation.

on @15:text:!* :#: {
  if ($1 == !die) part $chan
  elseif ($1 == !fart) describe $chan lets one rip $iif($2 ison $chan,at $2) $+ .
  else notice $nick Nope, Access Denied.
}

You can see where I used $iif to add "at somenick" if the user typed !fart somenick.
If they don't specify a nick, then nothing else is added. (no false condition is required)

- Raccoon
Posted By: KoRn18 Re: $iif - 28/08/03 07:25 PM
well my problem is i have many if !blah == $1 statments and then i have if staments in that, so if there was a way to simplfy it that'd be nice
Posted By: LocutusofBorg Re: $iif - 28/08/03 07:31 PM
For each condition you must use one if statement. Using $iif is possible, but to get it working right, you would have to start nesting $iif's, which is even worse than using multiple if's.

Besides, in the end how the code looks isn't imprtant.
Posted By: KoRn18 Re: $iif - 28/08/03 07:32 PM
ok... thanks smile
Posted By: Raccoon Re: $iif - 28/08/03 07:34 PM
on @15:text:!* :#: {
if ($1 == !die) {
    other statements
    part $chan
  }
elseif ($1 == !fart) describe $chan lets one rip $iif($2 ison $chan,at $2) $+ .
else notice $nick Nope, Access Denied.
}

Your script is as complex as you make it. If there are some global if-statements that are alike for multiple triggers, there are many ways of consolidating your code so you don't have to repeat the same check over and over in each one.

- Raccoon
Posted By: lammkott Re: $iif - 28/08/03 07:38 PM
You can try something like this...

1) Make an ini file with the following setup;
[commands]
!die=<enter commands for !die>
!blah=/msg $chan $nick said blah!


2) Use an if statement in your TEXT event to check whether the command is listed
if ($readini(commands.ini,commands,$1)) { return }
else { do this }


This will only need one if statement and you can add/delete commands with ease just by using /writeini, /remini
© mIRC Discussion Forums