mIRC Home    About    Download    Register    News    Help

Print Thread
Need help with trigger and flood #259737 19/01/17 02:51 PM
Joined: Mar 2016
Posts: 50
T
TUSK3N Offline OP
Babel fish
OP Offline
Babel fish
T
Joined: Mar 2016
Posts: 50
So This might be really easy to do but I still need help since im out of luck.

on *:TEXT:!hi:#:{
msg $chan hi $nick
}

so this just a script example but I want it to trigger on when someone says this

!hi
and
!hi blablabla

I know that you can add a *
on *:TEXT:!hi*:#:{

but then it triggers on everything like
!hiblablabla

and if I change it to this
on *:TEXT:!hi *:#:{

someone has to say this for it to trigger
!hi blablabla
and
!hi
doesnt work.

so how do I do this?

and also a thing about flood, can I have it in milliseconds instead of seconds?

if (%floodsay) { return }
set -u2 %floodsay On

this will have 2 seconds but can I do it like

1100 milliseconds?
1.1 seconds.

Re: Need help with trigger and flood [Re: TUSK3N] #259738 19/01/17 03:27 PM
Joined: Aug 2016
Posts: 36
ruprecht Offline
Ameglian cow
Offline
Ameglian cow
Joined: Aug 2016
Posts: 36
Use !hi* for the match text, and inside the event handler use $1 and $2- to test for a valid trigger and text after !hi

Code:
on *:TEXT:!hi*:#:{
  if ($1 != !hi) { return }
  elseif (!$2-) { msg $chan hi $nick }
  else { msg $chan hi $nick you said $2- }
}


You can unset a variable as you desire using a timer with the -m option
Code:
if (%floodsay) { return }
set %floodsay On
.timer -m 1 1100 unset %floodsay

Re: Need help with trigger and flood [Re: TUSK3N] #259749 22/01/17 02:38 AM
Joined: Oct 2015
Posts: 112
B
Blas Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2015
Posts: 112
Another way that would work would be to use regex.

Code:
ON $*:TEXT:/^!hi(\s\w+)?$/iS:#: {
  msg $chan hi $nick
}

The above says to trigger the script on either JUST "!hi" OR "!hi" followed by a SPACE \s followed by any number of word characters, numbers or underscores together \w+. The $ at the start simply means to use regex. The two /'s simply means that is what is to be evaluated. The ^ means that that is where the line has to begin (in this case, has to be begin with !hi). The ? in (\s\w+)? means that \s\w+ is optional. The \s means that it has to be a whitespace character (a space). The \w+ means that it has to be one or more word characters, numbers or underscores. The $ means that is where the line has to end. The i in iS means that it is case insensitive, and the S means to strip any mIRC codes from the message.

works: !hi
works: !hi there
works: !hi there_person13
doesn't work: !hithere
doesn't work: !hi $#@*
doesn't work: !hi there buddy

Last edited by Blas; 22/01/17 02:40 AM.