mIRC Home    About    Download    Register    News    Help

Topic Options
#44643 - 28/08/03 08:09 PM $iif
KoRn18 Offline
Vogon poet

Registered: 18/08/03
Posts: 148
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..
_________________________
_________
may death strike you.

Top
#44644 - 28/08/03 08:21 PM Re: $iif
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
$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
_________________________
Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Top
#44645 - 28/08/03 08:25 PM Re: $iif
KoRn18 Offline
Vogon poet

Registered: 18/08/03
Posts: 148
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
_________________________
_________
may death strike you.

Top
#44646 - 28/08/03 08:31 PM Re: $iif
LocutusofBorg Offline
Hoopy frood

Registered: 23/03/03
Posts: 1271
Loc: Sunnydale, CA
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.
_________________________
DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius

Top
#44647 - 28/08/03 08:32 PM Re: $iif
KoRn18 Offline
Vogon poet

Registered: 18/08/03
Posts: 148
ok... thanks smile
_________________________
_________
may death strike you.

Top
#44648 - 28/08/03 08:34 PM Re: $iif
Raccoon Offline
Hoopy frood

Registered: 18/02/03
Posts: 2594
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
_________________________
Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Top
#44649 - 28/08/03 08:38 PM Re: $iif
lammkott Offline
Fjord artisan

Registered: 12/05/03
Posts: 215
Loc: Australia
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
_________________________
- Jason

Top