mIRC Home    About    Download    Register    News    Help

Print Thread
add delay to on text msg #269104 12/06/21 12:46 AM
Joined: Jun 2021
Posts: 6
T
tribalcoi Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jun 2021
Posts: 6
I have set up on text msgs but i need a 1-3 second delay before they are sent. How do i add this?

Re: add delay to on text msg [Re: tribalcoi] #269107 12/06/21 04:13 PM
Joined: Jul 2006
Posts: 3,790
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,790
Use timer, check this page, the example section has what you need, watch out for timer injection though.

https://en.wikichip.org/wiki/mirc/commands/timer


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: add delay to on text msg [Re: Wims] #269109 13/06/21 03:24 AM
Joined: Jun 2021
Posts: 6
T
tribalcoi Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jun 2021
Posts: 6
Ty I have the timers figured out and all is good.

I have a new issue id like to work out if you can help out.

If the user spams the trigger, how would i go about getting it to respond only to the first trigger and ignore the rest for a set time?

Re: add delay to on text msg [Re: tribalcoi] #269110 13/06/21 01:44 PM
Joined: Mar 2010
Posts: 145
Masoud Offline
Vogon poet
Offline
Vogon poet
Joined: Mar 2010
Posts: 145
You can set a (dynamically named) variable when you the code is executed the first time, and check for it the next.
I've been away for a long time, and a bit rusty, but this might help.

Code
ON *:TEXT:*:*:{
  // Check if the variable is set, if not then perform the rest of the code.
  if ($eval($+(%,Timeout.,$chan,$nick),2) != 1) {

    // use -u switch to unset the variable after N seconds.
    set -u3 $+(%,Timeout.,$chan,$nick) 1

    // Do whatever is supposed to happen the first time here...
  }
}


Nothing...
Re: add delay to on text msg [Re: Masoud] #269111 13/06/21 02:31 PM
Joined: Jul 2006
Posts: 3,790
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,790
One trick would be to use a named timer for his timer, and then you can achieve the same logic by checking if the timer 'exists'


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: add delay to on text msg [Re: Masoud] #269112 13/06/21 02:49 PM
Joined: Jun 2021
Posts: 6
T
tribalcoi Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
T
Joined: Jun 2021
Posts: 6
This is what im working with right now. It works great as long as the user doesnt spam the trigger. If they spam it i want to only react to the first occurance and ignore the rest of them.

Code
on *:TEXT:sample:#channel:{ timer 1 8 msg #channel !play }


Im moderate with python and ahk but this is killing me.