mIRC Home    About    Download    Register    News    Help

Print Thread
#243113 15/10/13 04:48 PM
Joined: Oct 2013
Posts: 10
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Oct 2013
Posts: 10
I made a script that lets people enter info. This is what I have:
Code:
on $*:text:!/btag add/Si:#:{
  if ($0 < 4) { msg # Insufficient parameters: Use !btag add <btag> <svr(s). Seperate multiple with ",". EX: US,EU> | return }
  writeini -n btag.ini $+(#,.,$nick) bTag $3
  writeini -n btag.ini $+(#,.,$nick) bTagSvr $4
  { msg $chan Added $nick $+ 's BattleTag as $3 on $4 server(s). }
}

Now, it does work correctly, but when someone explains how to add it to their account, say, "Use !btag add blah blah" it will run the command. Is there a way to make it so it makes sure the message starts with "!btag add" before it runs the script and to keep looking for parameters?

This is my first script BTW.

Skullmonkey #243114 15/10/13 06:16 PM
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
In regex use the ^ anchor to match the start, $ is used to match the end. Also I don't know how having the ! outside of the / / would behave, keep it inside. Other than that, you also need to worry about the second word starting with add: !btag addition would also match.

Unless you're doing something more complex, rather than worrying about all these regex quirks, a simple wildcard would do the trick.

Code:
on *:text:!btag add *:#:{

Skullmonkey #243118 16/10/13 10:41 PM
Joined: Oct 2013
Posts: 10
S
Pikka bird
OP Offline
Pikka bird
S
Joined: Oct 2013
Posts: 10
That worked perfect. Thanks.

Skullmonkey #243124 17/10/13 10:54 AM
Joined: Aug 2013
Posts: 33
F
Ameglian cow
Offline
Ameglian cow
F
Joined: Aug 2013
Posts: 33
Maybe using something like:
Code:
on *:text:*:#: {
  if ($1 == !btag)
    if ($2 == !add)
      if ($0 < 4) {
        msg $chan Insufficient parameters: Use !btag add <btag> <svr(s)> (Seperate multiple servers with commas (Example: US,EU,AU).)
        return
      }
      else {
        var %btagini btag.ini $+(#,.,$nick)
        writeini -n %btagini bTag $3
        writeini -n %btagini bTagSvr $4
        msg $chan Added $nick $+ 's BattleTag as $3 on $4 server(s).
      }
      else {
        msg $chan Insufficient parameters.
      }
    }
  }
}

This way you can add more code in 1 "on text"-thingy.


Link Copied to Clipboard