mIRC Home    About    Download    Register    News    Help

Print Thread
#83854 22/05/04 11:40 PM
Joined: Oct 2003
Posts: 143
D
Vogon poet
OP Offline
Vogon poet
D
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.

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.


if (Windows isin %txt.1) { /kick # $nick Windows is a badword tisk tisk tisk. }
#83855 23/05/04 12:12 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.
#83856 23/05/04 12:16 AM
Joined: Oct 2003
Posts: 143
D
Vogon poet
OP Offline
Vogon poet
D
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.


if (Windows isin %txt.1) { /kick # $nick Windows is a badword tisk tisk tisk. }
#83857 23/05/04 01:04 AM
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
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.

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


hi.txt:
Hi there $nick
What's up $nick $+ ?

#83858 23/05/04 10:05 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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

Last edited by FiberOPtics; 23/05/04 10:09 AM.

Gone.
#83859 23/05/04 10:15 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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])


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#83860 23/05/04 10:35 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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


Gone.
#83861 23/05/04 03:43 PM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
write greet.txt HI there $!nick
write greet.txt Hi
write greet.txt Whats up $!nick
on *:text:hi:#:{ msg $chan $read(greet.txt) }


New username: hixxy
#83862 24/05/04 06:48 PM
Joined: Oct 2003
Posts: 143
D
Vogon poet
OP Offline
Vogon poet
D
Joined: Oct 2003
Posts: 143
Well thanks so much guys you are all a big help. Dident think id get so many replys


if (Windows isin %txt.1) { /kick # $nick Windows is a badword tisk tisk tisk. }

Link Copied to Clipboard