mIRC Home    About    Download    Register    News    Help

Topic Options
#33774 - 03/07/03 02:03 PM while loops
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
on *:part:#:{
var %i 1
if ($nick == $me) {
while (%i <= $did(switch,4).lines) {
did -ck switch 4 %i
$iif($did(switch,4).seltext == $chan,did -d switch 4 %i,inc %i)
}
}
elseif ($nick != $me) {
while (%g <= $did(switch,7).lines) {
did -ck switch 7 %g
$iif($did(switch,7).seltext == $nick,did -d switch 7 %g,inc %g)
}
}
}

the first part works, removing the channel from list when i part..., but removing the nickname doesnt work frown


Edited by pheonix (03/07/03 02:10 PM)
_________________________
new username: tidy_trax

Top
#33775 - 03/07/03 02:51 PM Re: while loops
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
Your code is unnecessarily slow. You don't need a while loop to find a line that matches a certain word/phrase. All you need is $didwm().
Code:
on me:*:part:#: if $didwm(switch,4,#) { did -d switch 4 $ifmatch }
on !*:part:#: if $didwm(switch,7,$nick) { did -d switch 7 $ifmatch }

However, I couldn't figure out from your post whether these lists (id 4 and 7) contain only 1 instance of the nick/channel or there are more. If the item appears in the list more than once, you need /filter.
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#33776 - 03/07/03 03:51 PM Re: while loops
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
i have a nicklist,and a channel list that i am. so when someone leaves/kicked/quits the channel to remove their nickname from 7, and when i leave to remove the channel name that i have just left.
_________________________
new username: tidy_trax

Top
#33777 - 03/07/03 05:29 PM Re: while loops
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
Alright, I got it right the first time. The code I showed you should do what you want. Look up $didwm() to see what it does, you're gonna like it eventually.
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#33778 - 03/07/03 06:02 PM Re: while loops
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
thats wicked grin

From the help file:
$didwm(name,id,wildtext,N)
Returns the number of the line that matches wildtext, with the search starting at line N. N is optional.

_________________________
new username: tidy_trax

Top
#33779 - 03/07/03 07:17 PM Re: while loops
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
i have another problem now grin

on *:Dialog:switch:sclick:4:{
did -r $dname 7
var %z 1
var %q 1
while (%z <= $comchan($me,0)) {
if ($comchan($me,%z) == $did(4).seltext) {
.set %channick $did(4).seltext
}
inc %z
}
while (%q <= $nick(%channick,0)) {
if ($nick(%channick,%q) isop $chan) {
did -a $dname 7 @ $+ $nick(%channick,%q)
inc %q
}
elseif ($nick(%channick,%q) ishop $chan) {
did -a $dname 7 % $+ $nick(%channick,%q)
inc %q
}
elseif ($nick(%channick,%q) isvoice $chan) {
did -a $dname 7 + $+ $nick(%channick,%q)
inc %q
}
if ($nick(%channick,%q) isreg $chan) {
did -a $dname 7 $nick(%channick,%q)
inc %q
}
}
/window -a %channick
did -r $dname 8
did -a $dname 8 Server: $server
did -a $dname 8 Channel: %channick
did -a $dname 8 Topic: $chan(%channick).topic
did -a $dname 8 Modes: $chan(%channick).mode
did -a $dname 8 Ops: $nick(%channick,0,o)
did -a $dname 8 Half Ops: $nick(%channick,0,h)
did -a $dname 8 Voiced: $nick(%channick,0,v)
did -a $dname 8 Normal Users: $nick(%channick,0,r)
did -a $dname 8 Total Users: $nick(%channick,0)
did -z $dname 8
}

the 2nd while loop freezes me frown

im trying to get it so its like mircs nicklist
@blah
%blah
+blah
blah
any help greatly appreciated grin
_________________________
new username: tidy_trax

Top
#33780 - 04/07/03 11:11 AM Re: while loops
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
You don't need a loop here either. You don't need to be bothered with adding the nicks in the list, nor with sorting them: just let /filter do it for you, by dumping the entire nicklist as it is to the dialog. I also modified the previous code I gave you; since you want to add the nicknames with their mode prefix (if any), you also need to tell $didwm() to look for nicks with prefixes. It's also important that you have on OP/DEOP/VOICE/DEVOICE/HELP/DEHELP events, to add/remove the mode prefix from the nicknames in ID 7.

Anyway, here's the code:
Code:
on me:*:part:#: if $didwm(switch,4,#) { did -d switch 4 $ifmatch }
on !*:part:#: if $didwm(switch,7,$pnick(#,$nick)) { did -d switch 7 $ifmatch }
alias pnick return $left($left($nick($1,$2).pnick,- $+ $len($2)),1) $+ $2
on *:Dialog:switch:sclick:4:{
  var %chan = $$did(4).seltext
  [color:red]filter -wocl %chan $dname 7[/color]
  window -a %chan
  did -ra $dname 8 Server: $server
  did -a $dname 8 Channel: %chan
  did -a $dname 8 Topic: $chan(%chan).topic
  did -a $dname 8 Modes: $chan(%chan).mode
  did -a $dname 8 Ops: $nick(%chan,0,o)
  did -a $dname 8 Half Ops: $nick(%chan,0,h)
  did -a $dname 8 Voiced: $nick(%chan,0,v)
  did -a $dname 8 Normal Users: $nick(%chan,0,r)
  did -a $dname 8 Total Users: $nick(%chan,0)
  did -z $dname 8
}
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#33781 - 04/07/03 12:15 PM Re: while loops
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
thankyou that works really well, accept for 1 thing frown
the half-ops come before the ops frown
_________________________
new username: tidy_trax

Top
#33782 - 04/07/03 12:42 PM Re: while loops
qwerty Offline
Hoopy frood

Registered: 07/01/03
Posts: 2523
This shouldn't be happening... I can't test any of this right now, but have you by any chance specified the sort style for the dialog listbox? (eg list 4, 100 100 100 100, sort). If you have, remove it, it is not needed.
_________________________
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Top
#33783 - 04/07/03 02:03 PM Re: while loops
pheonix Offline
Hoopy frood

Registered: 06/05/03
Posts: 2265
i took sort of, works fine now, thanx grin
_________________________
new username: tidy_trax

Top