mIRC Homepage

simple text script help

Posted By: kaceysparkles

simple text script help - 11/10/18 05:51 AM

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.

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

Posted By: maroon

Re: simple text script help - 11/10/18 07:32 AM

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.

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 }

© 2019 mIRC Discussion Forums