| | 
| 
| 
|  |  
| 
Joined:  Oct 2003 Posts: 143 Vogon poet |  
| OP   Vogon poet Joined:  Oct 2003 Posts: 143 | 
ok I been trying to make a on text event that would say a random sentece that I have for that word this is what i have so far and it isent working.  on 1:TEXT:Hi:#:/msg # $rand(HI there $nick,Hi,Whats up $nick) Why dosent this work? I tryed it and got k-lined off some server >< for flooding. Can someone tell me how to make a random text line.  |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2004 Posts: 2,013 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2004 Posts: 2,013 | 
Hello, it doesn't work because you are misusing the $rand function. One possible solution would be:  $rand(v1,v2)  
on *:TEXT:Hi:#: var %a = $rand(1,3) | msg # $iif(%a == 1,Hi there $nick,$iif(%a == 2,Hi,Whats up $nick))This works in two ways. If you supply it with numbers for v1 and v2, it returns a random number between v1 and v2. If you supply it with letters, it returns a random letter between letters v1 and v2. $rand(a,z)   returns a letter in the range a,b,c,...,z $rand(A,Z)  returns a letter in the range A,B,C,...,Z $rand(0,N)  returns a number in the range 0,1,2,...,N Greetz   |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2003 Posts: 143 Vogon poet |  
| OP   Vogon poet Joined:  Oct 2003 Posts: 143 | 
Thanks alot its was my first time working with rand and the mIRC help me file dident really give me a clear meaning of how to use it. Now that i see how you made it work I think i can figure it out thanks alot.  |  |  |  
| 
| 
|  |  
| 
Joined:  Apr 2003 Posts: 701 Hoopy frood |  
|   Hoopy frood Joined:  Apr 2003 Posts: 701 | 
If the number of trigger words is limited, you could use a text file for each word, with each reply on a single line and use $read. Type /help $read and look at the first example for $read. Also remember that the trigger you gave only responds to "Hi", not to "Hi DfD" or whatever. A last point: with the current script, you will be kickbanned on some channels, so make sure you have permission from the channel operators (or are one yourself), and limit it to only those channels.  on 1:TEXT:Hi:#chan1,#chat:{
  msg # $read(hi.txt)
}hi.txt: Hi there $nick What's up $nick $+ ?
 |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2004 Posts: 2,013 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2004 Posts: 2,013 | 
You're quite welcome, note that there are always multiple ways of achieving something. Here's another one :    
on *:TEXT:Hi:%chans:{
  goto $rand(1,3)
  :1 | msg # Hi there $nick | return
  :2 | msg # Hi             | return
  :3 | msg # Whats up $nick | return
}
or perhaps:    
on *:TEXT:Hi:%chans:{
  var %a = $rand(1,3)
  if (%a == 1) msg # Hi there $nick 
  elseif (%a == 2) msg # Hi 
  elseif (%a == 3) msg # Whats up $nick 
}
And as Kelder suggested, that worx great as well:  on *:TEXT:Hi:%chans: msg # $read(hi.txt) Note that I put a variable now as the possible channels. That means that in your variable section (alt+r -variables) you will have to put a variable  %chans  and use as values the channels you want the script to trigger in, like  #chan1,#chan2,#chan3 Just go with what suits you best, Greetz    
Last edited by FiberOPtics; 23/05/04 10:09 AM.
 |  |  |  
| 
| 
|  |  
| 
Joined:  Jan 2003 Posts: 2,125 Hoopy frood |  
|   Hoopy frood Joined:  Jan 2003 Posts: 2,125 | 
And yet another one: on *:text:hi:#chans: msg # $gettok(Hi there $nick [color:red]/[/color]Hi[color:red]/[/color]What's up $nick,$r(1,3),[color:red]47[/color]) |  |  |  
| 
| 
|  |  
| 
Joined:  Feb 2004 Posts: 2,013 Hoopy frood |  
|   Hoopy frood Joined:  Feb 2004 Posts: 2,013 | 
Hehe, yep, yet another one! A small suggestion, if the original poster would want to make use of this one, to put the various possible greetings in a variable, as the $gettok would screw up if he used comma's in his greeting. So:    
on *:TEXT:hi:#chans:{ var %greet = Hi there, $nick /Hi/What's up, $nick | msg # $gettok(%greet,$r(1,3),47) }
Greetz   |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2003 Posts: 2,321 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2003 Posts: 2,321 | 
write greet.txt HI there $!nickwrite greet.txt Hi
 write greet.txt Whats up $!nick
 on *:text:hi:#:{ msg $chan $read(greet.txt) }
 |  |  |  
| 
| 
|  |  
| 
Joined:  Oct 2003 Posts: 143 Vogon poet |  
| OP   Vogon poet Joined:  Oct 2003 Posts: 143 | 
Well thanks so much guys you are all a big help. Dident think id get so many replys  |  |  |  | 
 |