mIRC Home    About    Download    Register    News    Help

Print Thread
S
spermis
spermis
S
I need a script that will show 1 2 3 or 4 random words from a list.
So when admin type !random 1 it will show 1 word, !random 2 - 2 words random 3 - 3 and random 4 - 4 words.. I need that it shows each word in new line like

First random word is word1
Second random word is wordziii
Third random word is wooooRRRd
Fourth random word is w0w

The list is .txt file words.txt and there is more than 500 words, so i need that it chooses it EXTREMELY randomlly.

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Use this. Change words.txt to whatever filename you're going to use.

Code:
on *:text:!random &:#: {
  if ($nick !isop $chan) { .notice $nick Only ops can use this command. | return }
  if ($2 !isnum 1-4) { msg $chan Invalid format: Use !random 1, !random 2, !random 3, or !random 4 | return }
  var %cnt = 1
  while (%cnt <= $2) {
     while ($istok(%words,%word,32) || %word == $null) {
       var %word = $read(words.txt)
     }
     var %words = %words %word
     var %num = $iif(%cnt = 1,First,$iif(%cnt = 2,Second,$iif(%cnt = 3,Third,$iif(%cnt = 4,Fourth))))
     msg $chan %num random word is %word
     inc %cnt
  }
}


Edited: fixed something and made it op-only.

Last edited by Riamus2; 17/03/07 02:30 PM.
S
spermis
spermis
S
works good.. could you do that only ops can type it?

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
See above.

Joined: Jan 2003
Posts: 2,125
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,125
Just a suggestion,

var %num = $gettok(First Second Third Fourth,%cnt,32)

is much more readable (and faster, although it doesn't matter here) than

var %num = $iif(%cnt = 1,First,$iif(%cnt = 2,Second,$iif(%cnt = 3,Third,$iif(%cnt = 4,Fourth))))

S
spermis
spermis
S
oh i maked that it uses user list.. but how to make that if you arent in user list it shows - You have to be in THE mans list to use this command.

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
Good point, qwerty.

spermis: Use $ulevel...

Code:
if ($ulevel != whatever) { msg $nick whatever | return }
else { do what needs done }

S
spermis
spermis
S
whatever is the user lists name?

Joined: Oct 2004
Posts: 8,061
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Oct 2004
Posts: 8,061
It's the level from the user list, yes.

/help access levels
/help $ulevel

So, if someone is in the user list as:

OP:nick!ident@host.com

Then OP would be what $ulevel equals when triggered inside an event like that.


Link Copied to Clipboard