Help coding Random Reply mIRC

By Exuviax on Apr 02, 2014

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 }
}

Comments

Sign in to comment.
iamfluffy   -  Mar 03, 2016

I need help with my random on text replies.. i have random on join replies working but text wont work.
Example:
on *:TEXT:!word: {
/set %word.rand $rand(1, 2)
if (%word.rand == 1) /msg $chan etc.
if (%word.rand == 2) /msg $chan etc.
}

iamfluffy  -  Mar 03, 2016

heh. I fixed it. XD
"on *:TEXT:!word:#: {"

Sign in to comment

iSleepless   -  Jan 20, 2015

Simple
on *:TEXT:Hello:#: {
var %RR $rand(1,3)
if (%RR == 1) { msg $chan Hello $nick $+ ! }
if (%RR == 2) { msg $chan Hey $nick $+ , and welcome! }
if (%RR == 3) { msg $chan Hi $nick $+ ! }

 Respond  
Akumu   -  Apr 10, 2014

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 }

Vegito  -  Apr 11, 2014

Why are you halting?

Nos  -  Apr 11, 2014

yeah, should only be

.msg $chan .......... 

but just the same :)

Nos  -  Apr 11, 2014

wear point "." behind msg
if you do not want to see the writing of the script that runs
as I wrote above code

Sign in to comment

ProIcons   -  Apr 05, 2014

Create a text with random answers... and just add this

on *:text:whatever:#:{ msg $chan $read(textfile) }

or

on *:text:whatever:#:{ msg $chan $read(textfile,$rand(1,$lines(textfile))) }

even though its the same thing. By default the $read without N , is reading a random line of your text

 Respond  
Nos   -  Apr 03, 2014
 on *:TEXT:Hello:#:{
  goto $rand(1,3)
  :1
  msg $chan Hey
  halt
  :2
  msg $chan hey
  halt
  :3
  msg $chan hey
  halt
} 

the best of me :P

Vegito  -  Apr 03, 2014

rofl xD

Nos  -  Apr 03, 2014

just kidding,,hehehe :P

Sign in to comment

Vegito   -  Apr 03, 2014

You should use the forum for your questions.

on *:TEXT:Hello:#:msg # $gettok(hey:hey:hey,$r(1,3),58)
 Respond  
Nos   -  Apr 02, 2014
 on *:TEXT:Hello:#:{
  var %randnumber = $rand(1,3)
  if (%randnumber == 1) msg $chan Hey
  if (%randnumber == 2) msg $chan hey
  if (%randnumber == 3) msg $chan hey
} 
Exuviax  -  Apr 03, 2014

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?

Meta  -  Apr 03, 2014

There shouldn't be. You were typing !roulette and what would happen, if anything?

Nos  -  Apr 03, 2014

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

Exuviax  -  Apr 03, 2014

It literally just will not respond with ! in front of the code...

Nos  -  Apr 03, 2014
  • yup *
Nos  -  Apr 03, 2014

as an example
[i] <@Nos> !roulette

sorry you can not use the command * Nos sets mode: -o Nos !roulette BANG! ... The bullet missed, you only have your born moderation powers to thank Nos [/i]
Nos  -  Apr 04, 2014

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)
  }
} 
pony_Buzzen  -  Apr 05, 2014

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 }
}

Nos  -  Apr 05, 2014
  • @pony_Buzzen : you should use: msg $chan *
Nos  -  Apr 05, 2014
 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

Meta  -  Apr 05, 2014

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.

Nos  -  Apr 05, 2014

@Meta : I think similar to

on *:TEXT:!Good:#:{
  goto $rand(1,3)
  :1
  msg $chan blablabla
  halt
  :2
  msg $chan blablabla
  halt
  :3
  msg $chan blablabla
  halt
} 
pony_Buzzen  -  May 07, 2014

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

Sign in to comment

Nos   -  Apr 02, 2014
 on *:TEXT:Hello:#:msg $chan $replace($rand(1,3),1,Hey,2,hey,3,hey) 
 Respond  
Meta   -  Apr 02, 2014

You're on the right track; the main problem is the parentheses around the $rand(1,3) -- It should just be:

var %randnumber $rand(1,3)

otherwise the ( ) will be part of the variable, (e.g. ( 1) rather than 1)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.