mIRC Homepage
Posted By: camckee316 Delay script - 26/04/18 04:19 AM
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.
Posted By: maroon Re: Delay script - 26/04/18 05:55 AM
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.
Posted By: Wims Re: Delay script - 26/04/18 08:11 AM
On text does trigger for yourself in query.
Posted By: camckee316 Re: Delay script - 26/04/18 09:11 PM
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.
Posted By: Wims Re: Delay script - 26/04/18 09:36 PM
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
Posted By: Raccoon Re: Delay script - 27/04/18 03:52 AM
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
Posted By: Wims Re: Delay script - 27/04/18 08:54 AM
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.
© mIRC Discussion Forums