mIRC Homepage
Posted By: Bestpeff (Twitch) Random responses for command - 06/06/16 04:40 PM
I'm trying to find a way for whenever someone says "hi" or "hello" etc... but have it have a different response EVERY time and I can have multiple responses instead of 2 or 3. If I could have help, it'd be greatly appreciated
Posted By: empeK Re: (Twitch) Random responses for command - 06/06/16 06:46 PM
How i do this stuff is:

I just add random number variable. And then add if statements for each random number how many you want.

Code:
on *:TEXT:hello:#: {
    var %rand = $rand(1,how many you want)
    
    if ( %rand == 1  ) {
       //do something
    }

    if( %rand == 2 ) {
      //do something
    }
    
   // and so on
}
Posted By: Bestpeff Re: (Twitch) Random responses for command - 07/06/16 07:53 AM
Works great but how do I set it so it only ignores me (Bestpeff) ?
Posted By: empeK Re: (Twitch) Random responses for command - 07/06/16 10:16 AM
You just add an IF statement for your name

Code:
 if ( $nick != Bestpeff ) { 

    //code 
 } 


or you can do it in another way

Code:
 if ( $nick == Bestpeff ) {

    return 
 } 
Posted By: Tulga Re: (Twitch) Random responses for command - 02/09/16 12:13 PM
with $rand and if statements it will be long script you can create txt file and fill it with bunch of messages like

randommsg.txt

Code:
hey!
hello!
welcomeback
howdy


then use this code:

Code:
on *:text:hello:#: {
  if ($nick == YOURNICK) { return }
  ; this will pick random line from "randommsg.txt" and use that
  msg # $read(randommsg.txt) 
}
© mIRC Discussion Forums