$read random line that is within two numbers - 06/01/05 07:48 AM
Hello, not sure if the topic describes this as well as i could. But here's the script with an explanation of what i am in need of:
as you can see when somone joins a channel it searches a text file (quotesubmitter.txt) to find the nick of the user who just joined.
when it finds a match, it uses $readn to call the same line from quotes.txt which corresponds to quotesubmitter.txt.
now the problem: what i don't want is for it to print the same quote every time the same person joins. So i need a way to make it start on a random line, so it will print basicly a random quote (submitted by that user) every time they join. The way i have done it was quick but buggy, ie, it returns 0 alot.
So if somone could come up with something tricky to make this less buggy and more effecient, i would gladly steal it
thanks in advance.
Code:
on *:join:#:{ set %random $time(ss) $read(quotesubmitter.txt, w, * $+ $nick $+ *, %random) if ($readn = 0) { /msg # Autoquote function error! (no quotes for user/buggy coding) halt } else { /msg # Random Quote Submitted by: $nick /msg # Quote $chr(35) $+ $readn $+ : $read(quotes.txt, $readn) } }
as you can see when somone joins a channel it searches a text file (quotesubmitter.txt) to find the nick of the user who just joined.
when it finds a match, it uses $readn to call the same line from quotes.txt which corresponds to quotesubmitter.txt.
now the problem: what i don't want is for it to print the same quote every time the same person joins. So i need a way to make it start on a random line, so it will print basicly a random quote (submitted by that user) every time they join. The way i have done it was quick but buggy, ie, it returns 0 alot.
So if somone could come up with something tricky to make this less buggy and more effecient, i would gladly steal it
thanks in advance.