mIRC Home    About    Download    Register    News    Help

Print Thread
How to randomize sequential responses....? #265500 16/05/19 02:38 PM
Joined: May 2019
Posts: 3
D
Dan2019 Offline OP
Self-satisified door
OP Offline
Self-satisified door
D
Joined: May 2019
Posts: 3
Hi guys ,

Below is an example of my script that triggers on channel JOIN...

on 1:JOIN:#:/timer 1 10 /msg $nick Welcome | /timer 1 20 If you like the game please vote on the main page | /timer 1 30 Thanks for visiting and enjoy your stay

I want to randomise the replies from a text file stored locally , how exactly do i do this ? I am quite new to mIRC and am just learning and have been testing used $rand but failed miserably lol. I am stumped on this one and could really use help . I'd like to have say 10 options for each sequential reply

Re: How to randomize sequential responses....? [Re: Dan2019] #265501 16/05/19 07:46 PM
Joined: Dec 2002
Posts: 2,010
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,010
If you use the $read identifier with no switches, it will read a random line from your file.

Replace <path\file.txt> with your own path and file name.

Code:
on 1:JOIN:#: {
 .timer 1 10 msg $nick Welcome
 .timer 1 20 msg $nick $read(<path\file.txt>)
 .timer 1 30 msg $nick Thanks for visiting and enjoy your stay
}


If you meant you want 10 responses to choose randomly for each message, you could create a file for the welcome messages, a file for the info messages and a file for the thank you messages...

Code:
on 1:JOIN:#: {
 .timer 1 10 msg $nick $read(<path\welcome.txt>)
 .timer 1 20 msg $nick $read(<path\info.txt>)
 .timer 1 30 msg $nick $read(<path\thanks.txt>)
}


Re: How to randomize sequential responses....? [Re: RoCk] #265504 17/05/19 06:11 PM
Joined: Feb 2003
Posts: 2,641
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,641
Alternatively:
Code:
  var %r = $rand(1,3)
  if (%r == 1) var %msg = Message one.
  if (%r == 2) var %msg = Message two.
  if (%r == 3) var %msg = Message three.

or
Code:
  var %msg = $gettok( $&
    Message one.@ $&
    Message two.@ $&
    Message three. $&
    , $rand(1,3) $&
    , $asc(@) $&
  )


Well. At least I won lunch.
Good philosophy, see good in bad, I like!