MIRC script with remote command - only use once per minute

2.4k views Asked by At

I have written a little mirc script, where if a regular chatter does .xcommand it will execute the alias /ycommand.

Now, because of over usage, I would like to limit it so a user can only use it once per minute. And I am not sure how to do it, I figure it would be something like:

on *:TEXT:.xcommand:#: {
if $user timer==0 /ycommand else goto *nothinghere*
}

I would appreciate if anyone could help me with this, I am quite new to mirc scripting! cheers

1

There are 1 answers

0
Kylar On

You can set a variable every time you use /ycommand which is automatically unset after 60 seconds. Then you can use an if statement around /ycommand to check whether the variable is set and if it is, do nothing because the command was used within the last 60 seconds.

The hard part is using a different variable for each user. When setting a variable, use %xcommandused. $+ $nick and the nick of the user will be a part of the variable name. For example, my nick is Kylar, so when I type .xcommand it will set %xcommandused.Kylar to $true.

It's not as simple when you want to read the value of the variable. You can use evaluation brackets like %xcommandused. [ $+ [ $nick ] ] or $eval like $eval(% $+ xcommandused. $+ $nick, 2).

If you have more questions, there's a good scripting community on the SwiftIRC network. Just connect to irc.swiftirc.net, join #mSL, explain your problem, and hope someone answers.

on *:TEXT:.xcommand:#: {
  if (!%xcommandused. [ $+ [ $nick ] ]) {
    set -u60 %xcommandused. $+ $nick $true
    ycommand
  }
}