mIRC Homepage
Posted By: DeathfireD Random text for word - 22/05/04 11:40 PM
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.

Code:
 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.
Posted By: FiberOPtics Re: Random text for word - 23/05/04 12:12 AM
Hello,

it doesn't work because you are misusing the $rand function.

One possible solution would be:
Code:
  
on *:TEXT:Hi:#: var %a = $rand(1,3) | msg # $iif(%a == 1,Hi there $nick,$iif(%a == 2,Hi,Whats up $nick))


$rand(v1,v2)
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
Posted By: DeathfireD Re: Random text for word - 23/05/04 12:16 AM
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.
Posted By: Kelder Re: Random text for word - 23/05/04 01:04 AM
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.

Code:
on 1:TEXT:Hi:#chan1,#chat:{
  msg # $read(hi.txt)
}


hi.txt:
Hi there $nick
What's up $nick $+ ?
Posted By: FiberOPtics Re: Random text for word - 23/05/04 10:05 AM
You're quite welcome,

note that there are always multiple ways of achieving something.

Here's another one :
Code:
  
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:
Code:
  
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:

Code:
 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
Posted By: qwerty Re: Random text for word - 23/05/04 10:15 AM
And yet another one:
Code:
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])
Posted By: FiberOPtics Re: Random text for word - 23/05/04 10:35 AM
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:
Code:
  
on *:TEXT:hi:#chans:{ var %greet = Hi there, $nick /Hi/What's up, $nick | msg # $gettok(%greet,$r(1,3),47) }

Greetz
Posted By: tidy_trax Re: Random text for word - 23/05/04 03:43 PM
write greet.txt HI there $!nick
write greet.txt Hi
write greet.txt Whats up $!nick
on *:text:hi:#:{ msg $chan $read(greet.txt) }
Posted By: DeathfireD Re: Random text for word - 24/05/04 06:48 PM
Well thanks so much guys you are all a big help. Dident think id get so many replys
© mIRC Discussion Forums