mIRC Homepage
Posted By: zu_yong !rules or any triggers with '!' - 04/08/03 12:35 PM
I am a newbie in irc. I would like to know how to set up a bot or script that uses the following triggers like '!rules' or '!commands'. Once the command is activated, a list of rules or commands would be listed out in sequence of 1. XX 2. XX

Thank you.
Posted By: Collective Re: !rules or any triggers with '!' - 04/08/03 12:41 PM
on *:TEXT:!rules:#:msg # 1. Foo 2. bar
Posted By: zu_yong Re: !rules or any triggers with '!' - 04/08/03 12:46 PM
Ummm...Can I have a simple example please? ^_^
I am still kinda confused...
Posted By: Collective Re: !rules or any triggers with '!' - 04/08/03 12:47 PM
That was an example, put it in your remotes (ALT+R) and have someone say !rules, it will message the channel with "1. Foo 2. bar"
Posted By: zu_yong Re: !rules or any triggers with '!' - 04/08/03 12:49 PM
Thank you.
I get a bit of the concept already ^_^

And by the way, how to I set the script to run on one specific channel only? I dun wan to start listing out !rules in other people's channel ^_^;
Posted By: Collective Re: !rules or any triggers with '!' - 04/08/03 01:33 PM
on *:TEXT:!rules:#channelname:msg # 1. Foo 2. bar

Just replace the green with the name of your channel.
Posted By: zu_yong Re: !rules or any triggers with '!' - 04/08/03 02:11 PM
Thank you again, Collective ^_^
You have been a big help to me ^_^
Posted By: zu_yong Re: !rules or any triggers with '!' - 04/08/03 04:16 PM
Oh...another question has arise...
How do I make the !rules trigger available only for the viewing of the person who typed the !rules trigger?
Posted By: Collective Re: !rules or any triggers with '!' - 04/08/03 04:18 PM
Send it as either a notice or a private message:

on *:TEXT:!rules:#channelname:notice $nick 1. Foo 2. bar
or
on *:TEXT:!rules:#channelname:msg $nick 1. Foo 2. bar
Posted By: zu_yong Re: !rules or any triggers with '!' - 04/08/03 04:32 PM
Ok...The previous settings are now ok...Thanks ^_^

Is there a way to align the output in this format : (vertical)
1. No spam
2. No cursing

rather than (horizontal)

1. No spam 2. No cursing ?

Because vertical indent looks much readable and neat ^_^
Posted By: pheonix Re: !rules or any triggers with '!' - 04/08/03 04:36 PM
make a text file and put each rule on a seperate line,call it rules, then use this.

Code:
alias rules {
var %i 1
while (%i <= $lines(rules.txt)) {
msg %nick %i $+ : $read(rules.txt,%i)
inc %i
}
}
on *:TEXT:!rules:#:{
set %nick $nick
/rules
}

Posted By: Collective Re: !rules or any triggers with '!' - 04/08/03 04:37 PM
on *:TEXT:!rules:#channelname:msg $nick 1. Foo | msg $nick 2. bar

or much more readable:
Code:
on *:TEXT:!rules:[color:green]#channelname[/color]:{
  msg $nick 1. Foo
  msg $nick 2. bar
}
Posted By: Collective Re: !rules or any triggers with '!' - 04/08/03 04:38 PM
That sends it to the channel rather than the user. Stop posting things people don't want!

Edit: You managed to fix one problem..

Edit2: Why not use /play instead of a while loop?

Edit3: You managed to fix both, you made something useful, congrats!
Posted By: pheonix Re: !rules or any triggers with '!' - 04/08/03 04:40 PM
heh
never had any use for /play so never bothered using it :tongue:
Posted By: zu_yong Re: !rules or any triggers with '!' - 04/08/03 04:41 PM
Gee...Thanks again guys (especially Collective)
This is the best irc help forum I have been to. I get replies to my questions in less than 2 minutes. Keep up the good work!
Posted By: Rich Re: !rules or any triggers with '!' - 04/08/03 05:52 PM
Some small improvements on your code:
Code:
alias rules {
  var %i = 1[color:red], %lines = $lines(rules.txt)[/color][color:green], %nick = $$1[/color]
  while (%i <= [color:red]%lines[/color]) {
    msg [color:green]%nick[/color] %i $+ : $read(rules.txt,[color:blue]tn[/color],%i) 
    inc %i
  }
}
on *:TEXT:!rules:#:rules [color:green]$nick[/color]

By using %lines mIRC won't have to determine the number of lines in rules.txt every time it checks the condition in the while loop
By passing $nick as $1 You won't have to use a global variable, which most people will agree is best to avoid. Also, now you can do /rules <nick> anywhere and it will msg that nick your rules. (Using double $'s will halt the alias if you don't specify a nickname)
Using the tn switches with $read is usually recommendable, or you have to make sure the first line of the file is not a number (t) and everything that can be evaluated should be evaluated (all words starting with % or $ are meant as variables and identifiers) (n)
Posted By: Urgntfury Re: !rules or any triggers with '!' - 05/07/04 11:35 PM
this is probably a really stupid question but here goes anyway. If I take the above code. where does it go? or better yet where do I put it. How do you start it. Or does it just work. Do you have to restart program.

thanks
Posted By: Rich Re: !rules or any triggers with '!' - 06/07/04 09:41 AM
You put the code in your remotes:
In mIRC, press [ALT][R], this opens up the remote tab of the script editor.
Now copy the code there and press the "OK" button, after that it works right away.
Make sure the rules.txt is in your mIRC directory or you will be getting errors though.
© mIRC Discussion Forums