| | 
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
This is an on ban event. It tries to set a variable by nick as $banmask. Say I have a variable like %bannick , nick1, nick2, nick3 Someone sets mode: +b 1Person %bannick = , nick1 I use $mid(%bannick,3) btw. But then, let's say. Someone sets mode: +b 3People Then. %bannick = , nick1, nick2, nick3 If.. %bannick = , nick1 Then I can /set %bnick $+ $mid(%bannick,3) $banmask To get: %bnickNick1 $banmask But what if I have %bannick = more than 1 nicks... How do I... /Set  % $+ bnick $+ $gettok($mid(%bannick,3),1,44) $banmask = % $+ bnick $+ nick1 $banmask = %bnickNick1 $banmask %bnickNick2 $banmask %bnickNick3 $banmask (Because all nicks have the same banmask for this case). Etc. My attempts, so far I've tried: /set % $+ $gettok($mid(bannick,3),1,44) $gettok($mid(%bannick,3),1,44) I'm guessing I will have to $+( ) it or $eval( ,2) the whole thing, or even $+($eval( ,2)) it even. Any suggestions? I just need to know how to dynamically link the name of the variables. My current failed code (unnecessary to question). 
  var %i = 1
  while (%i <= $gettok($mid(%bannick,3),0,44)) {
    /set % $+ $gettok($mid(bannick,3),%i,44) $gettok($mid(%bannick,3),%i,44)
    /set %bnick $+ $gettok(%bannick,%i,44) $banmask
    inc %i
  }
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
If ist not about storing many bnicks / bmasks, I'd suggest to use a simple addtok. set %banstring $addtok(%banstring,$+($iif(($bnick),$bnick,-none-),$chr(44),$bmask),32)this will produce a single variable %banstring. e.G. there was: mode # +b Nick1!user@* mode # +b *!*@93754.telecomitalia.com mode # +b Nick2!*@*.ipt.aol.com The data will look like: Nick1,Nick1!user@* -none-,*!*@93754.telecomitalia.com Nick2,Nick2!*@*.ipt.aol.com Please note that "$bnick" is $null if a ban contains no nickname at all. Therefore I used that $iif(($bnick),$bnick,-none-) To parse data, use token identifiers, eg: grab the 3nd bnick: $gettok($gettok(%banstring,3,32),1,44) grab the 2nd bmask: $gettok($gettok(%bansgring,2,32),2,44) delete the first bnick-bmask in the var: set %banstring $deltok($banstring,1,32) |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
Maybe this will help you with "dynamically numbering" variable's names. The first part here shall demonstrate what method I used... alias incvarname.demo {
  set %ban.5 bnick5 bmask5
  set %ban.3 bnick3 bmask3
  set %ban.1 bnick1 bmask1
  set %ban.2 bnick2 bmask2
  ; how many vars matching %ban.* do I have at all?
  var -s %total = $var(%ban.*,0)
  ; whats the name of the last variable? (mIRC sorts them: "last" means alphanumeric highest, not "last added")
  var -s %last = $var(%ban.*,%total)
  ; now I got that var's name, what was the number at the end of that variable?
  ; Note: that "6" depends on the variable name's length)
  var -s %num = $mid(%last,6)
  ; and what number do I need now?
  var -s %newnum = $calc(%num +1)
  ; so what new varname do I need?
  var -s %newvar = $+(%,ban.,%newnum) some new data
  unset %ban.*
}this uses the method demonstrated above, but shortens it a lot   ; syntax: /incvarset variable-root varable-data
; e.g. /incvarset ban. $iif(($bnick,$ifmatch,-none-) $bmask
alias incvarset {
  if ($1) { set $+(%,$1,$calc($mid($var($+(%,$1,*),$var($+(%,$1,*),0)),$calc($len($1) +2)) +1)) $2- }
} |  |  |  
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
Okay it seems I was confused. Let me call this "while loop error." * Someone sets mode: +b letter Ban affects 3 nicks. 
  echo $chan $gettok($mid(%bannick,3),1,44)
  echo $chan $gettok($mid(%bannick,3),2,44)
  echo $chan $gettok($mid(%bannick,3),3,44)
  echo $chan $gettok($mid(%bannick,3),0,44)
  var %i = 1
  while (%i <= $gettok($mid(%bannick,3),0,44)) {
    /set %bnick $+ $gettok($mid(%bannick,3),%i,44) $banmask
    inc %i
  }
[July 15 2007 Sunday 03:43:11 PM] * Neal` sets mode: +b f*!*@* found_20 found_22 Fara7oOo 3 Well, only %bnickfound_20 was made, but not the other 2. In other words, the while loop only goes round the 1st time, even though 1 < 3... -Neal. |  |  |  
| 
| 
|  |  
| 
Joined:  Dec 2002 Posts: 3,534 Hoopy frood |  
|   Hoopy frood Joined:  Dec 2002 Posts: 3,534 | 
Why don't you use $ialchan ?  Then loop through the matches.  Using $ialchan(*!*@*,$chan,0).nick for example: 
On *:Ban:#: {
  var %x = 1
  while (%x <= $ialchan($banmask,$chan,0)) {
    echo -a $ialchan($banmask,$chan,%x).nick
    inc %x
  }
}
Just change the echo bit to how you stored the nicknames before. |  |  |  
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
Okay, you totally came up with a different solution to solve my problem. And that's also good in my book. So I have. 
  var %x = 1
  while (%x <= $ialchan($banmask,$chan,0)) {
    echo $chan $ialchan($banmask,$chan,%x).nick
    /set %bnick $+ $ialchan($banmask,$chan,%x).nick $banmask
    inc %x
  }
Then I got %bnickNick1 $banmask %bnickNick2 $banmask %bnickNick3 $banmask Then, for the unban event, I have the same thing, except I used /unset %bnick $+ $ialchan($banmask,$chan,%x).nick. That didn't unset it. I guess I have to play around with it, using [ ] or $eval(). |  |  |  
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
No luck.
 I've tried.
 
 /unset %bnick [ $ialchan($banmask,$chan,%x).nick) ]
 /unset $+(%bnick,$ialchan($banmask,$chan,%x).nick)
 /unset $+(%,bnick,$ialchan($banmask,$chan,%x).nick)
 /unset $+($eval(%,bnick,$ialchan($banmask,$chan,%x).nick,2))
 
 Heh. :\
 
 |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
Looks like I misunderstood your question, sry. However, this works for me: on *:ban:#:{
  var %x = 1
  while ($ialchan($banmask,$chan,%x).nick) {
    set -s %bnick $+ $ifmatch $banmask
    inc %x
  }
}
on *:unban:#:{ 
  var %x = 1
  while ($ialchan($banmask,$chan,%x).nick) {
    unset -s $+(%,bnick,$ifmatch)
    inc %x
  }
}[00:37:17] * Horstl|Fortl sets mode: +b *o*!*@* * Set %bnickHorstl|Fortl to *o*!*@* * Set %bnickMaestro to *o*!*@* [00:37:21] * Horstl|Fortl sets mode: -b *o*!*@* * Unset %bnickHorstl|Fortl * Unset %bnickMaestro
Last edited by Horstl; 15/07/07 10:36 PM.
 |  |  |  
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
Wow, thanks so much!
 I got it working.
 
 [uly 15 2007 Sunday 05:36:41 PM] * Neal` sets mode: +b f*!*@*
 Ban affects found_20, found_22, Fara7oOo.
 Ban also afftects fractorial, FireHose, floyd-ZzZzZ, FlipKonijn.
 [July 15 2007 Sunday 05:36:52 PM] * Neal` sets mode: -b f*!*@*
 Unban affects found_20, found_22, Fara7oOo.
 Unban also affects fractorial, FireHose, floyd-ZzZzZ, FlipKonijn.
 
 Ban affects = users in channels, ban also affects = users outside the channel in my matching IAL comchans.
 
 And then I setted 3 variables for the ban affects nicks and unsetted them when unbanned.
 
 Thanks again.
 
 -Neal.
 |  |  |  
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
And just for a small minor change, I did not use $ifmatch because I needed the variable. 
  var %x = 1
  while ($ialchan($banmask,$chan,%x).nick) {
    /timernotice $+ %x 1 %x /notice $ialchan($banmask,$chan,%x).nick Unbanned in $chan
    /unset $+(%,bnick,$ifmatch)
    inc %x
  }
* Timer notice1 activated * Timer notice2 activated * Timer notice3 activated [July 15 2007 Sunday 05:43:25 PM] -> -found_20- Unbanned in #8 * Timer notice1 halted [July 15 2007 Sunday 05:43:26 PM] -> -found_22- Unbanned in #8 * Timer notice2 halted [July 15 2007 Sunday 05:43:26 PM] -> -Fara7oOo- Unbanned in #8 * Timer notice3 halted While this isn't a large issue, I can't actually use $+ $chan in /timer, since ops could be unbanning in different channels, that could mess up the numeric order. But I shall/can cope. :] |  |  |  
| 
| 
|  |  
| 
Joined:  Nov 2006 Posts: 1,552 Hoopy frood |  
|   Hoopy frood Joined:  Nov 2006 Posts: 1,552 | 
Just a note: you might get probs... As your variable names depend on nicknames. Nicks can change. You cannot be asure the right variables will unset. Scenario:
 
 Assume a user Joe!friend@somehost
 * banning: *!friend@*
 Now, you'll store a %bnickJoe *!friend@*
 * Joe changes nick to Joe|away
 * unbanning: *!friend@*
 
 > Your script will try to unset %bnickJoe|away, as the user part of his addres is still "friend" but there is no such var.
 > Same problem if Joe parts / quits / gets kicked: You will keep variables that are of no use any more.
 To echo users affected by ban / unban, why do you need to set variables at all? Just loop the $ialchan and $ial to pick the names...
 |  |  |  
| 
| 
|  |  
| 
LostShadow
 |  
| LostShadow | 
Yea I'm aware, I actually don't set variables when echoing ban and unbanned nicks. One of my echo's, if in a comchan, will show the updated nick. Unban affects: Person Unban also affects: Person|sleep Usually though, it's pointless to let them know they're unbanned.   |  |  |  | 
 |