mIRC Home    About    Download    Register    News    Help

Print Thread
Delay script #262943 26/04/18 04:19 AM
Joined: Dec 2017
Posts: 9
C
camckee316 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2017
Posts: 9
is there a better way to write this script. the delay is to prevent spamming of command.

Code:
on !1:TEXT:*karp*:#:{
  if (!%comwait) {
    set -u60 %comwait 1
    describe $chan steals the karp and brings it to PP!
  }
  else echo karp thief cooldown time is in session. No stealing yet.
}


thank you.

Re: Delay script [Re: camckee316] #262944 26/04/18 05:55 AM
Joined: Jan 2004
Posts: 1,178
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,178
1. the TEXT is one of the events not triggered by anything you type into a channel or query window, so the "!" prefix has no effect and can be removed.

2. *karp* matches those 4 letters anywhere in the line, but in this case i doubt it would ever be part of a normal word.

3. This is the way I often see these delays used, but often I see 2 kinds of delays, where there's 1 cooldown delay for the entire channel as a whole, and a different cooldown delay for each nick. Rather than creating dynamic variables, you can avoid that by using them in a hash table:
Code:
on *:TEXT:*karp*:#:{
  if ($hget(karp,$nick) || $hget(karp,$chan)) { echo $chan karp thief cooldown time is in session. No stealing yet. | return }
  hadd -mu30 karp $chan $chan
  hadd -mu60 karp $chan $nick
  describe $chan steals the karp and brings it to PP!
}


4. The hash table disappears from memory, and can only be saved, by saving it to a disk file with the /hsave command or then retrieved from disk with the /hload command. This also avoids the small chance that your temporary variable gets saved to disk when mIRC saves the variables list to disk, but then your computer crashes before it can be unset 60 seconds later. Then the next time you restart mIRC, the %comwait variable will be there without knowing the variable should be unset. If you'll use global variables, you'd want to have an ON START event to unset any such variables.

Re: Delay script [Re: maroon] #262945 26/04/18 08:11 AM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
On text does trigger for yourself in query.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Delay script [Re: Wims] #262949 26/04/18 09:11 PM
Joined: Dec 2017
Posts: 9
C
camckee316 Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
C
Joined: Dec 2017
Posts: 9
Originally Posted By: Wims
On text does trigger for yourself in query.

No

maroon again thank you for sharing you knowledge. *karp* is a pokemon and the owner of the irc channel likes magikarps, therefore when someone says *karp* the bot is to steal a karp and take to the channel owner (PP). i only really need one delay, for the entire channel(s). again marron i thank you.

Re: Delay script [Re: camckee316] #262950 26/04/18 09:36 PM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
Yeah it does, maroon did not mention your on text event specifically, he talked about on text event in general.
Code:
on *:text:*:?:echo -s triggered


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: Delay script [Re: Wims] #262962 27/04/18 03:52 AM
Joined: Feb 2003
Posts: 2,642
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,642
You guys need to speak clearly.

The On Text event triggers for yourself, for query messages SENT TO YOURSELF. That is, when the message comes back to you from the server.

//query $me


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: Delay script [Re: Raccoon] #262963 27/04/18 08:54 AM
Joined: Jul 2006
Posts: 3,559
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,559
I am very clear, there is no need to specify the 'sent to yourself' part since that's irrelevant: in query, it triggers for you or anyone else, not just for you only.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net