mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
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,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.

Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
works good.. could you do that only ops can type it?

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


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
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))))


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
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,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Good point, qwerty.

spermis: Use $ulevel...

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


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2007
Posts: 91
S
spermis Offline OP
Babel fish
OP Offline
Babel fish
S
Joined: Feb 2007
Posts: 91
whatever is the user lists name?

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard