mIRC Home    About    Download    Register    News    Help

Print Thread
simple text script help #263920 11/10/18 05:51 AM
Joined: Oct 2018
Posts: 1
K
kaceysparkles Offline OP
Mostly harmless
OP Offline
Mostly harmless
K
Joined: Oct 2018
Posts: 1
hey guys ive been digging around for weeks now and cant find/get to work what im looking for (bit of a overwhelmed newbie). i need two things added to this.

first: i need the !command to only trigger after the keywords been typed in the chat xx amount of times.

second: when the channel is idle/no messages after xx amount of time leave channel and or unload the script.

seems simple but i suck so thanx in advance for any help or insight its much appreciated.


Code:
ON *:TEXT:!command:#kaceysparkles: {
  if (%flood.#kaceysparkles) { return }
  set -u20 %flood.#kaceysparkles On
  msg $chan commands message
}



Last edited by kaceysparkles; 11/10/18 07:30 AM.
Re: simple text script help [Re: kaceysparkles] #263921 11/10/18 07:32 AM
Joined: Jan 2004
Posts: 1,167
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,167
The first event handler creates a hashtable item that lives for 20 seconds, then dies. Then it finds how many hashtable items begin with flood, then does nothing if there's less than 5 of them.

As for monitoring if the channel is idle enough:

//echo -a $chan(#kaceysparkles).idle

shows how many seconds the channel has been idle. It doesn't count JOIN and QUIT and various other events, so if you want those to reset the idle back to zero, you'll have to trap those other events beyond :TEXT: and :ACTION: then do like I did below, where each time the :TEXT: event happens in channel, it updates the hashtable item to contain the newest $ctime value. Then you can have a timer that compares the current $ctime against $hget(kaceysparkles,idle) to see if it's been long enough.

Code:
ON *:TEXT:!command:#kaceysparkles:{
  var %unique $hget(kaceysparkles,unique) | inc %unique | hadd -m kaceysparkles unique %unique | hadd -m kaceysparkles idle $ctime
  hadd -u20 kaceysparkles flood $+ %unique $nick
  if ($hfind(kaceysparkles,flood*,0,w) < 5) return
  msg $chan commands msg 
}

ON *:TEXT:*:#kaceysparkles:{ hadd -m kaceysparkles idle $ctime }