Can someone help me code a IF/ELSE Statement that has 5 different replies, and when you type the command in chat it pics a random sentence out of the 5 and replies. Probably using $rand, I for the life of me can't figure it out, and I am SUPER new to mIRC. So here is what I got (Don't be too harsh)
on *:text:Hello:#: {
var %randnumber ( $rand(1,3))
if (%randnumber = 1) {
msg $chan Hey 1 }
if (%randnumber = 2) {
msg $chan hey 2 }
if (%randnumber = 3) {
msg $chan hey 3 }
}
Basic Script, I added one for Bye as well. Enjoy :)
on :text:Hello:#: {
set %reply $rand(1,5)
if (%reply == 1) { msg $chan Hey there }
elseif (%reply == 2) { msg $chan Hey }
elseif (%reply == 3) { msg $chan Hi! }
elseif (%reply == 4) { msg $chan Hello }
elseif (%reply == 5) { msg $chan Hey there, $nick }
}
on :text:Bye:#: {
set %reply2 $rand(1,5)
if (%reply2 == 1) { msg $chan Good bye }
elseif (%reply2 == 2) { msg $chan Cya }
elseif (%reply2 == 3) { msg $chan Take Care! }
elseif (%reply2 == 4) { msg $chan Bye }
elseif (%reply2 == 5) { msg $chan Peace out, $nick }
on *:TEXT:!roulette:#: {
if ($nick !isop #) {
var %randmods = $rand(1,3)
if (%randmods == 1) msg $chan Roulette click!...Empty...You live to see another day $nick
if (%randmods == 2) msg $chan BANG! ... You were shot but live. There must be secert powers in your mod armor $nick
if (%randmods == 3) msg $chan BANG! ... The bullet missed, you only have your born moderation powers to thank $nick
}
else { RETURN }
}
So I am making a Roulette system, and I want the Mods to have different replies than the non-mods. I am lost again.
EDIT:
I went back and removed the ! from Roulette and now it works, is there something about having ! that wreaks the code?
If you do not want ops to use the command "!roulette"
on *:TEXT:!roulette:#:{
if ($nick !isop $chan) {
var %randmods = $rand(1,3)
if (%randmods == 1) msg $chan Roulette click!...Empty...You live to see another day $nick
if (%randmods == 2) msg $chan BANG! ... You were shot but live. There must be secert powers in your mod armor $nick
if (%randmods == 3) msg $chan BANG! ... The bullet missed, you only have your born moderation powers to thank $nick
}
else {
msg $chan sorry you can not use the command
}
}
:D
let no lot line
on *:TEXT:!roulette:#:{
if ($nick !isop $chan) {
var %randmods = Roulette click!...Empty...You live to see another day $nick $+ |BANG! ... You were shot but live. There must be secert powers in your mod armor $nick $+ |BANG! ... The bullet missed, you only have your born moderation powers to thank $nick
msg $chan $gettok(%randmods,$rand(1,3),124)
}
}
on *:TEXT:Hello:#:{
.set %msg.nick $snick($active,1) | .set %msg.chan $active $chan | /set %RandomAnswer $rand(1,8)
if (%RandomAnswer == 1) { msg $active %msn.chan Hello %msg.nick :) }
if (%RandomAnswer == 2) { msg $active %msn.chan Hi There %msg.nick :p }
if (%RandomAnswer == 3) { msg $active %msn.chan Hey %msg.nick :0 HIIIIIII Ya }
if (%RandomAnswer == 4) { msg $active %msn.chan Hello %msg.nick :P how you doing }
if (%RandomAnswer == 5) { msg $active %msn.chan :) %msg.nick hi there :D }
if (%RandomAnswer == 6) { msg $active %msn.chan Hey %msg.nick Welcome back :p }
if (%RandomAnswer == 7) { msg $active %msn.chan Hey Good to see ya %msg.nick how you doing :) }
if (%RandomAnswer == 8) { msg $active %msn.chan Were ya been %msg.nick Hi there :p }
}
on *:TEXT:Hello:#:{
.set %msg.nick $nick | .set %msg.chan $chan | .set %RandomAnswer $rand(1,8)
if (%RandomAnswer == 1) { msg %msg.chan Hello %msg.nick :) }
if (%RandomAnswer == 2) { msg %msg.chan Hi There %msg.nick :p }
if (%RandomAnswer == 3) { msg %msg.chan Hey %msg.nick :0 HIIIIIII Ya }
if (%RandomAnswer == 4) { msg %msg.chan Hello %msg.nick :P how you doing }
if (%RandomAnswer == 5) { msg %msg.chan :) %msg.nick hi there :D }
if (%RandomAnswer == 6) { msg %msg.chan Hey %msg.nick Welcome back :p }
if (%RandomAnswer == 7) { msg %msg.chan Hey Good to see ya %msg.nick how you doing :) }
if (%RandomAnswer == 8) { msg %msg.chan Were ya been %msg.nick Hi there :p }
}
:D
One small note first off: elseif should be used after the first if, otherwise, mIRC will check every condition, even if one has already worked.
Exuviax - Do you have any other on TEXT events above the roulette one? Particularly, any like on :TEXT:!:#: ? There's nothing about using an ! that would cause the script to not work, but having a non-specific event like that, could.
pony_Buzzen - nos is right: $active returns the name of the currently active window... Which means, for example,that if somebody triggers your script in #stuff, and #what is your currently active window, you'll msg #what with the response.
But nos. Why use variables for $nick and $chan? And why global o_O
Another possible way to go about something like this, btw, would be to just put the responses - one per line - in a plain text file, and use $read() to return a random line from that file (which it will by default)
Example: Say this is the content of a file called "goodblankresponses.txt" in your $mircdir:
Good morning!
Good afternoon!
Good evening!
Good bye.
Good going.
Good game.
Good riddance!
Good thing proicons beat me to the $!read() suggestion.
Then you could just simply create a script like:
on *:TEXT:!Good:#:msg # $read(goodblankresponses.txt)
Which when triggered, would respond with one of the lines from that file.
i understand that . but he reason why i use msg $active and set channel is if on more then one rooms it will msg the channel were said word was , and not the my own active channel , if im talking else were . I also use the read short commands
.set %msg.nick $snick($active,1) | .set %msg.chan $active $chan
But after looking at your coding closer , i can see what you mean , but at the same time , on buzzen mine works now and it aint broke dont fix it LOL
thank you for the reply
I will remeber your advice on my next release
heh. I fixed it. XD
"on *:TEXT:!word:#: {"