mIRC Home    About    Download    Register    News    Help

Print Thread
#126865 05/08/05 06:53 PM
Joined: Aug 2005
Posts: 3
F
farky Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Aug 2005
Posts: 3
hi, i wanna make a jokebot for my channel:

Code:
 on 1:TEXT:!joke:#: {

  %num = $rand(1,5)

  if (%num == 1) /msg $chan 1. joke
  if (%num == 2) /msg $chan 2. joke
  if (%num == 3) /msg $chan 3. joke
  if (%num == 4) /msg $chan 4. Joke
  if (%num == 5) /msg $chan 5. Joke 
}


its working, but i dont know, how to make that: if some1 typed '!joke', then write the joke, but then dont write anything for 5 minutes if some1 types '!joke'.

plz help, and sorry for my english blush


-farky
Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Code:
 on 1:TEXT:!joke:#: {
if ( !%joke ) {
  set -u300 %joke 1
  var %num = $rand(1,5)
  if (%num == 1) /msg $chan 1. joke
  if (%num == 2) /msg $chan 2. joke
  if (%num == 3) /msg $chan 3. joke
  if (%num == 4) /msg $chan 4. Joke
  if (%num == 5) /msg $chan 5. Joke 
 }
} 


Or like this

Code:
 on 1:TEXT:!joke:#: {
if ( !%joke ) {
  set -u300 %joke 1
  msg $chan $read(joke.txt)
 }
} 


You'll have to create a text file called joke.txt in your mIRC folder & put all your jokes in there. When a person types !joke, the script will give a random joke from the file. Also this has the anti-flood for 5 mins per your request.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Aug 2005
Posts: 3
F
farky Offline OP
Self-satisified door
OP Offline
Self-satisified door
F
Joined: Aug 2005
Posts: 3
its working, thx laugh


-farky
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Here's an example just like xDaemon's except using Hash Tables to store data, just so you don't fill up your vars tab with variables..

Also tells them how long they must wait till they can use the command again.

Code:
on 1:TEXT:!joke:#: {
  if (!$hget(joke)) hmake joke
  if (!$hget(joke,$nick)) {
    hadd -z joke $nick 300
    if ($exists(joke.txt)) msg $chan $read(joke.txt)
  }
  else { 
    msg $chan $nick Please wait $duration($hget(joke,$nick).unset) until using this command.
    halt
  }
}


-Andy

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
In my code, it will only set one global variable so it will not fill up the variables section this way it affects every person who uses the command. Yours is nice too since it's nick-specific.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Ohh yeah so it is, my mistake I just assumed you'd set a var for each nickname.. smile

My apologies.

-Andy


Link Copied to Clipboard