mIRC Home    About    Download    Register    News    Help

Print Thread
#257458 11/04/16 02:31 AM
Joined: Apr 2016
Posts: 5
W
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
W
Joined: Apr 2016
Posts: 5
I am trying to learn scripting and have been going through the examples from wikichip.org. All of the examples have worked so far, until I got to the events. None of them work, not even the most simple. I have checked the scripts editor Listen menu and the Events option is checked. Any ideas?

http://en.wikichip.org/wiki/mirc/on_event
here is one of the samples I've tried:
Code:
on *:text:!help:#:{
  notice $nick For Help just state your question and pastebin any relevant code.
}



Thanks.

Last edited by wmcritter; 11/04/16 02:36 AM.
Joined: Apr 2016
Posts: 5
W
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
W
Joined: Apr 2016
Posts: 5
No ideas at all?

Bueller?
Bueller?

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Hello, the example is fine and should be working, put the code in a new remote file and see if it works, if so, you had a conflict with another event in your current remote file


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #257490 15/04/16 12:32 AM
Joined: Apr 2016
Posts: 5
W
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
W
Joined: Apr 2016
Posts: 5
I tried that, but not working either. frown
Thanks for the suggestion. Any other ideas?

Joined: Apr 2016
Posts: 5
W
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
W
Joined: Apr 2016
Posts: 5
Ok, here is something strange. It works, but not for me. In the example I posted, if I type !help, nothing happens. But if anyone else types it, it works fine.
It's annoying that I can't test my own events, but at least it's working.

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
ah, then it's all good, because that's expected.
IRC Events are tied to the IRC protocol, when you send a message to a channel, you don't get a message from the server, where on text only triggers when you get a privmsg from the server. The on input event will trigger for your own text, here is something you can do not to duplicate the code:
Code:
on *:text:!help:#:{
do_test $nick
}
on *:input:#:{
if ($1- == !test) do_test $me
}
alias do_test {
 notice $1 For Help just state your question and pastebin any relevant code.
}


Last edited by Wims; 15/04/16 01:03 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #257493 15/04/16 01:20 AM
Joined: Apr 2016
Posts: 5
W
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
W
Joined: Apr 2016
Posts: 5
Cool, thanks for the info.

I've got another question, if you don't mind.
I'd like to put a time restriction on my response. For example, if you type !dostuff and then !dostuff again, I only want the response to be generated if more than 3 seconds have passed since the first !dostuff. I figure it would be pretty simple to populate a global variable with the last time !dostuff was called, then compare that against the current time when the second !dostuff is called. But so far I have only found the $time command to get the current time, and it does not look like it will be very easy to work with. Is there a better way to get the current time and compare it with a time in a variable?
Thanks.

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
This is called a cooldown, or just anti flood, you can search this forum for that and you'll get a lot of results, but what you want is quite simple, set a variable which will last 3 secs when you process the !dostuff, and check the variable doesn't exist before doing so:

Code:
on *:text:!help:#:{
  if (!%antiflood) {
    do_test $nick
    set -u3 %antiflood 1
  }
}
-u3 means the variable will be unset automatically after 3 seconds, we give the variable the value 1 as a bool value, if (!%antiflood) basically means 'if the variable isn't set'


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard