Kranium31   -  Mar 14, 2014

I am trying to make a mirc sript where a quote comes up randomly when i type !somesay.

I have mastered getting quotes to come with different keyowords but how exactly do i make them come up randomly?

Any help is appreciated. :)

[AFX]  -  Mar 14, 2014

; usage: /random_quote #channel
; you must be in #channel for this to work
; you must include the # when using command

;ex: /random_quote #mychannel would msg the channel with a random line read from textfile (you specify the location to the file you want to read from)

alias random_quote {
if ($1) && ($chr(35) !isin $1) { echo -a ERROR: $1 isn't a valid channel | return }
else {
var %l = $rand(0,$lines(textfile.txt))
$iif($me ison $1,.msg $1 $read(textfile.txt,%l))
}
}

with some basic error checking.

Kranium31  -  Mar 15, 2014

How do I specify the text file that its reading from? Do I just put the text files name and it does it on its own?

Also how to I make the command !somesay? I don't see that part here it's different from my other scripts.

[AFX]  -  Mar 15, 2014

Do you want it so that if you say the trigger it will say something? Or when other users say the trigger?

[AFX]  -  Mar 15, 2014

See in the alias where itsays textile.txt? Replace that with the path and filename of the file you're reading from

[AFX]  -  Mar 15, 2014

Either way, for your trigger you want to look at the on *:text event

Kranium31  -  Mar 15, 2014

I want all users to be able to say the trigger.

[AFX]  -  Mar 15, 2014

on *:text:!somesay:#channel: { random_quote $chan }

Another observation, my alias works %100, but if you're worried that if on the client that the script is loaded in, you dont see any output coming from you, its because i made the /msg command silent (.msg instead of msg). If you want to see yourself on the same client actually message the channel with a random quote, remove the . from msg.

Now, if you want this to happen in multiple channels, there are a few ways you can go about that, but I'll let you figure that one out on your own.

Kranium31  -  Mar 15, 2014

So where do i put that with the in your original script?

[AFX]  -  Mar 15, 2014

In your mirc remotes?

Kranium31  -  Mar 15, 2014

Well yes thats a given.

Does this *on :text:!somesay:#channel: { random_quote $chan }** go with the other part of your script or is it stand alone?

[AFX]  -  Mar 15, 2014

Because I didn't specify alias -l in the alias, they can be stored in seperate files. You can keep them together if you want. I just provided the alias that will generate a random line and message it to a #target. The on TEXT event is in regards to your trigger since you didn't understand how that worked.

Kranium31  -  Mar 15, 2014

I understand the on text event. Just not the way you explained everything. Forgive me I'm new to this. Thanks for the help. My testing hasn't gone well. I couldn't get it to work.

[AFX]  -  Mar 15, 2014

paste here what you have

Kranium31  -  Mar 15, 2014

this is what i have now

on *:text:!somesay:#channel: { random_quote $chan }
alias random_quote {
  if ($1) && ($chr(35) !isin $1) { echo -a ERROR: $1 isn't a valid channel | return }
  else {
    var %l = $rand(0,$lines(stigquotes.txt))
    $iif($me ison $1,describe $1 $read(stigquotes.txt,%l))
  }
}
Kranium31  -  Mar 15, 2014

i did change the channel but it keeps giving me an error that !somesay isnt a valid channel

[AFX]  -  Mar 15, 2014

Paste exactly what you have. I tested this before publishing and it worked on my end.

[AFX]  -  Mar 15, 2014

Are you having someone else do the trigger?

Kranium31  -  Mar 15, 2014

I am also trying a simpler script at the same time. Can't get either to work.

On *:Text:*:#:{
  if (!somesay isin $1-) {
    describe $chan $read(stigquotes.txt)
  }
}
[AFX]  -  Mar 15, 2014

you might as well just try this and forget what i posted above:

on *:text:!somesay:#channel_name_here: { .msg #channel_name_here $read(textfile.txt,$rand(0,$lines(textfile.txt))) }

modify the channel name and the text file name

[AFX]  -  Mar 15, 2014

do you have multiples of the same events in the same remote? eg:

on :text::#: { some code here }
on :text::#: { some other code here}

Kranium31  -  Mar 15, 2014

No i edited the one i had in there. Trying that now.

Kranium31  -  Mar 15, 2014

It does help if its in code tags because its all jumbled.

Kranium31  -  Mar 15, 2014

This is what you mean?

Kranium31  -  Mar 15, 2014
On *:Text:!somesay:#gearheads: { 
  describe #gearheads01 $read(stigquotes.txt,$rand(0,$lines(stigquotes.txt))
    } 
 } 
Kranium31  -  Mar 15, 2014

Not working. And incase there is any doubt i do have the text file in my mirc folder, I have tried putting it in the main folder, the default folder and the scripts folder. Just incase i had it in the wrong place.

[AFX]  -  Mar 15, 2014

The above appears to have an extra closing brace, on line 3 or 4 depending on how you look at it. Honestly, all of the above should work.

Kranium31  -  Mar 15, 2014

I removed the extra closing brace. Still doesn't work.

I also tried this but still doesn't work. I'm not getting any errors anymore though.

On *:Text:!somesay:$chan:{ 
  describe $chan $read(stig.txt,$rand(0,$lines(stig.txt)))
}   
[AFX]  -  Mar 15, 2014

How are you testing? Are you trying to say the trigger in the channel from the same client this script is loaded in? Or do you have another user saying the trigger? All of this should be working.

Kranium31  -  Mar 15, 2014

I'm testing with another user that is me as a mod. And other users in channel have been trying also.

Kranium31  -  Mar 16, 2014

Turns out the problem is I didn't have the text file in the right directory. I found a thread online that explained how to find the right directory and moved it there. After that it works.

Thanks for the help

[AFX]  -  Mar 16, 2014

no problem

Sign in to comment

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.