mIRC Homepage
Posted By: DrStein Variable VS group - 11/12/04 03:46 AM
Lets say you want to make an option in you away system that it will disable all protections while you are away

You can do this either by putting a variable (lets say %awayprotection OFF while you are away and you want the protections to be off) or by creating a different file and put there all the protection events ina Group

My Question is which one is better and why? confused
Posted By: Danthemandoo Re: Variable VS group - 11/12/04 04:02 AM
I personally prefer groups, and i don't think either method is better than the other.

Its just a personal preferance as to which you use i suppose.
Posted By: tidy_trax Re: Variable VS group - 11/12/04 08:46 AM
I'd say groups are better because you don't have to perform an if () check to check a groups value, you do for variables.
I prefer using variables.
Posted By: starbucks_mafia Re: Variable VS group - 11/12/04 05:53 PM
I'd say groups are better because the setting is then embedded in the code rather than in a separate file which a variable would be. It's also 'safer' in case the variable gets unset by a curious user or bad code (ie. unset %*).
Posted By: DrStein Re: Variable VS group - 11/12/04 06:34 PM
First of all thanks for the replys smile

Groups are better when the groups is off but,what about when the group is on? confused

For example lets say we have two on TEXT events.The first one is the protections on text and it has
if (badword iswm $1-) { kick the user out and DO NOT do any other action in on text event }

The second one may have inside a fan bot which will reply to some words a bot which will count words etc.

If you use one on text is very easy with if elseif or halt/return
to execute only if (badwords iswm $1-) andignore the rest of the code (If this is what you want)

But how can you do it if you use groups confused
Which one of the two On text events will mirc read first confused
Posted By: Iori Re: Variable VS group - 11/12/04 08:59 PM
miRC executes commands/events in the same order the files are loaded.
You could by have the group earlier in the same file,
Code:
#groupname on
on *:text:word:#:{
  ...
  ...
  halt(def)
}
#groupname end
on *:text:word:#:{
  ...
  ...
}

or put your groups in a file loaded first and use the '&' prefix in the second, third etc files.
Code:
[color:gray]file1.mrc[/color]
#groupname off
on *:text:word:#:{
  ...
  ...
  halt(def)
}
#groupname end
Code:
[color:gray]file2.mrc[/color]
on [color:red]&[/color]*:text:word:#:{
  ...
  ...
}
The second event won't be triggered in either case.
/help prefixes


For commands you [don't] want exectuded when your away you could also just do
"if $away { ... }" (or "if !$away { ... }"


The & prefix can also be used without the #group BTW.
Posted By: DrStein Re: Variable VS group - 11/12/04 09:12 PM
I have to admit that i have forgotten the & blush
© mIRC Discussion Forums