mIRC Home    About    Download    Register    News    Help

Print Thread
#64936 23/12/03 04:38 AM
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
Yeah, it's me again...

How do I count the number of user arguments ($$1, $$2...) there are for any given command, and how would I go about checking each one?


Kewlio
Insanity is all I have to keep from becoming insane.
#64937 23/12/03 04:49 AM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
$0 and
Code:
  var %i = 1
  while ( $eval($ $+ %i,2) ) {
    echo -a $ifmatch
    inc %i
  }


Edit: Typo, started %i at 0..

Last edited by Collective; 23/12/03 05:02 AM.
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
OK, this is to be used with some more Remote code. It's an On Mode function. Here's what it looks like so far:

Code:
on *:mode:#:{
  var %i = 1
  while ( $eval($ $+ %i,2) ) {
    var %j = $i + 1
    if ( $left($ifmatch,1) == + ) {
      if (l isin $1-) /echo 14 -t # 8MODE: 7User Limit to $eval($ $+ %j,2) <- $nick
      if (k isin $1-) /echo 14 -t # 8MODE: 7Password is $eval($ $+ %j,2) <- $nick
      if (t isin $1-) /echo 14 -t # 8MODE: 7Topic Lock <- $nick
      if (m isin $1-) /echo 14 -t # 8MODE: 7Channel Moderation <- $nick
    }
    elseif ( $left($ifmatch,1) == - ) {
      if (l isin $1-) /echo 14 -t # 8MODE: 7No User Limit <- $nick
      if (k isin $1-) /echo 14 -t # 8MODE: 7Password removed <- $nick
      if (t isin $1-) /echo 14 -t # 8MODE: 7Topic Unlock <- $nick
      if (m isin $1-) /echo 14 -t # 8MODE: 7Free Chat <- $nick
    }
    inc %i
  }
}


Two problems: When it comes to bringing up the number of limited users or new password to the channel, it doesn't show up right. Second, none of the "Off" modes seem to work. (Turn off a mode, and it doesn't show up.)

EDIT: Those $1- should be $ifmatch...

Last edited by KewlioMZX; 23/12/03 05:24 AM.

Kewlio
Insanity is all I have to keep from becoming insane.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
you can be the first (or one of) to test out an alias i made of what i want Mr. Mardem-bey to add >:D

EDIT: Sorry, I changed a lil, plus wanted to test out my new alias. Anyways, here wat it'll look like if you do it with the alias. grin

Code:
; new mode identifier
; by kingtomato
; -
; usage:
;  after using $mode for so ling, and trying to match up the letter
;  with the appropriate $mode(N), I got tired of it. So I write a
;  lil snipplet that does just that.  The way it works is just like
;  $mode when no proerties are attached. When they are attached, it
;  can return the character of mode N, or its associated parameter.
;  i.e. a ban will return b for its character, and the nick/mask
;  thats being banned for its parameter.  Here's the break down:
;
; syntax:
;  $modes(N)
;    Gets the Nth mode
;  Properties:
;    .chr  - Gets the mode character associated with the mode
;            This will return ONLY the letter (ex: o)
;    .sign - returns the sign of the mode change (ex: +)
;    .mode - returns the mode being set (ex: +o
;
;  syntax 2:
;    /modes <modes>
;    modes - the current mode string being set.  Because this is a
;            custom identifier, I have no means of having it be
;            'auto called' with the mode change. What you have to do
;            is call this before using the variable. Much like a dialog
;            dll such as mdx, you have to 'set' the modes we're going
;            to be parsing before you can use them.
;            
;  So for example, something like a mode change of:
;    +ovp KingTomato KingTomato
;  would return:
;
;  $modes(1)       = KingTomato (Like Normal)
;  $modes(1).chr   = o
;  $modes(1).sign  = +
;  $modes(1).mode  = +o
;
;  $modes(2)       = KingTomato (Again, normal)
;  $modes(1).chr   = v
;  $modes(1).sign  = +
;  $modes(1).mode  = +v
;
;  $modes(3)       = $null
;  $modes(3).chr   = p
;  $modes(1).sign  = +
;  $modes(1).mode  = +p
alias modes {
  ; if it if being used as an identifier ($modes)
  if ($isid) {
    ; set a variable that's easy to work with
    var %modes = %unique_modes_var      | ; variable we are parsing
    var %mode  = $gettok(%modes, 1, 32) | ; just the +this-that part

    ; here we loop through each letter of the mode change. When we find
    ; one that has params that should be associated to it, we put both
    ; the letter, and the parameter together seperated by a colon.  If
    ; a colon should conflict, then please change the variable below to
    ; another char.
    var %param   = 2 | ; Starting gettok value for associations
    var %letter  = 1 | ; letter number we're lookin at in %mode
    var %modeNum = 1 | ; numeric count of the current mode (compared to $1)
    var %delim   = : | ; this is what will seperate the letter from the param

    ; begin to loop through the %mode value
    while ($mid(%modes, %letter, 1)) {
      ; easier to deal with
      var %chr = $ifmatch

      ; check for a mode sign (+/-)
      if (%chr isin +-) var %sign = %chr
      ; not a sign, its a letter
      else {
        ; check for a letter that has a paramter with it
        if ((%chr isincs $gettok($chanmodes, 1-3, 44)) || (%chr isincs qaohv)) {
          ; this has a mode, now we get the parameter that corrisponds to it
          var %curMode = $+(%sign,%chr,$chr(%delim),$gettok(%modes, %param, 32))
          ; add it to the list of modes
          var %modeList = %modeList %curMode

          ; we used a param, increase the coutner
          /inc %param
        }
        ; its jsut a letter mode (like +s, +p, etc)
        else var %modeList = %modeList $+(%sign,%chr)

        ; check if this is a mode the user is requesting
        if ($1 == %modeNum) {
          ; do they want the chr, or its mode
          if ($prop == chr) return %chr
          else if ($prop == sign) return %sign
          else if ($prop == mode) return $+(%sign,%chr)
          else return $mid(%curMode, 3)
        }

        ; moving onto next mode, increase count
        /inc %modeNum
      }

      ; goto next letter
      /inc %letter
    }

    ; 0 as a mode, for total count
    if ($1 == 0) return %curMode

    ; default
    return $null
  }

  ; being used as a command
  else {
    ; I'd use some var like %modes, but i don't want it to interfere
    ; with other's scripts. I'm also using /set because we're not parsing
    ; what's being passed, just setting it into somethign we can deal with
    ; when the time comes
    /set -u0 %unique_modes_var $1-
  }
}
on *:rawmode:#:{
  /modes $1-
  var %m = 1
  while ($modes(%m).chr) {
    ;
    ; ---------- Addition
    ; limit (+l)
    if ($modes(%m).mode == +l) /echo 14 -t # 8MODE: 7User Limit to $modes(%m) <- $nick
    ; key (+k)
    if ($modes(%m).mode == +k) /echo 14 -t # 8MODE: 7Password is $modes(%m) <- $nick
    ; ops set topic (+t)
    if ($modes(%m).mode == +t) /echo 14 -t # 8MODE: 7Topic Lock <- $nick
    ; moderated (+m)
    if ($modes(%m).mode == +m) /echo 14 -t # 8MODE: 7Channel Moderation <- $nick
    ;
    ; ---------- Removal
    ; no limit (-l)
    if ($modes(%m).mode == -l) /echo 14 -t # 8MODE: 7No User Limit <- $nick
    ; no key (-k)
    if ($modes(%m).mode == -k) /echo 14 -t # 8MODE: 7Password removed <- $nick
    ; anyone sets topic (-t)
    if ($modes(%m).mode == -t) /echo 14 -t # 8MODE: 7Topic Unlock <- $nick
    ; no moderation (-m)
    if ($modes(%m).mode == -m) /echo 14 -t # 8MODE: 7Free Chat <- $nick
    ;
    /inc %m
  }
}

Last edited by KingTomato; 23/12/03 05:39 AM.

-KingTomato
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
That's really great and all, but I'm making Remote scripts not Alias scripts...

EDIT: Sorry, I didn't look at the whole thing... I'll look at this further :tongue:

EDIT2: I keep getting an Unknown Command error with this new script...

Last edited by KewlioMZX; 23/12/03 06:23 AM.

Kewlio
Insanity is all I have to keep from becoming insane.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Where at?


-KingTomato
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
I don't know. All I know is that when the script is invoked, it constantly gives me "Unknown Command" in the status window until I quit/restart mIRC.


Kewlio
Insanity is all I have to keep from becoming insane.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
No line number? No nothing?


-KingTomato
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
No line number, no nothing. Just Unknown Command.


Kewlio
Insanity is all I have to keep from becoming insane.
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
To aid debugging please type: /debug @debug and see what it is sending the server.

Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
I get a lot of these:

<- :SanJose.CA.us.undernet.org 421 KewlioMZX   :Unknown command

EDIT: I've noted that they almost always come between:

-> SanJose.CA.us.undernet.org PRIVMSG KewlioMZX :FLOODCHECK

and:

<- :KewlioMZX!nunuvur@nwcsts09c008.nbnet.nb.ca PRIVMSG KewlioMZX :FLOODCHECK

except at the very end.

Last edited by KewlioMZX; 23/12/03 07:08 AM.

Kewlio
Insanity is all I have to keep from becoming insane.
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Flood check is another script--not mine.


-KingTomato
Joined: Aug 2003
Posts: 29
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2003
Posts: 29
Flood Check is an mIRC option, not really a script. Anyhow, I turned it off, and it seems to be stopping on the line that sets %unique_mode_var to 1 for 0 seconds.


Kewlio
Insanity is all I have to keep from becoming insane.

Link Copied to Clipboard