mIRC Home    About    Download    Register    News    Help

Print Thread
#53024 09/10/03 12:09 AM
Joined: Oct 2003
Posts: 8
A
Aazn Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Oct 2003
Posts: 8
Okay, I've got a botlist script:

Code:
dialog botlist {
  title "Botlist [/botlist]"
  size -1 -1 200 200
  option dbu

  list 12, 1 1 100 200
  check "There is currently a bot" 5, 120 10 100 10
  button "Assign" 1, 120 30 30 10, ok
  button "Cancel" 2, 120 50 30 10, cancel

}
on *:Notice:*:?:{
  if ($nick == Botserv) && ($1 !isnum) && ($1 !== Bot) { /did -a botlist 12 $1 }
}
on *:DIALOG:botlist:init:0:{
  did -a botlist 12 Bot List
  did -a botlist 12  
  /msg botserv botlist
}
on *:DIALOG:botlist:sclick:1:{
  /set %Botname $did(botlist,12).seltext
  //msg botserv assign $active %Botname
  /echo 3 -a Bot successfully assigned to #
  /echo 3 -a Thank you for using Aazn Listbot
  /unset %botname
}


Right now, all it does is list the available botserv bots, with a "Assign" and "Cancel" button's that work. I have a checkbox there for partially the script.

What I need is for you guys to help me figure out what to put to make it automatically detect that there is a bot in there, and unassign it before assigning a new one.

- Aazn


( www.nnscript.de )
#53025 09/10/03 01:24 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
There are 3 ways to do that.

The first one is looping through $nick($active,%var) and using $didwm() to check whether one of them is found in the bot list. In this case, you'll ask botserv to remove that nick from the channel. Example:
Code:
On *:dialog:botlist:sclick:1:{
  var %# = $active, %b = $did(12).seltext
  if !%b || $me !ison %# { halt }
 
 
  var %i = $nick(%#,0)
  while %i {
    if $didwm(12,$nick(#%,%i)) {
      msg botserv unassign %# $did(12,$ifmatch)
      break
    }
    dec %i
  } 
 
 
  msg botserv assign %# %b
  echo 3 -a Bot successfully assigned to %#
  echo 3 -a Thank you for using Aazn Listbot
}


Another way is looping through $did(botlist,12,%var), and using the "ison" operator to check whether one of the listed bots is on the channel, in which case botserv will be asked to remove it. For example,
Code:
  var %i = $did(12).lines
  while %i {
    if $did(12,%i) ison %# {
      msg botserv unassign %# $ifmatch
      break
    }
    dec %i
  }


The third way is my favorite, because no loop is needed there. We use $didtok() to return the content of the listbox as a single string, make up a regular expression pattern out of it, and use the new regex feature of $fline() to scan the side-listbox of the channel for a matching nick. Here's an example,
Code:
  var %r = ^[ $+ $prefix $+ ]?( $+ $replace($didtok(12,10),\,\\,$chr(123),\{,[,\[,^,\^,|,\|,$lf,|) $+ )$
  if $fline(%#,%r,1,3) {
    msg botserv unassign %# $nick(%#,$ifmatch)
  }  

Now you can pick up whatever idea you like laugh

Edit: fixed $replace x 4 :tongue:


Link Copied to Clipboard