mIRC Home    About    Download    Register    News    Help

Print Thread
on JOIN and a while loop. #193131 15/01/08 12:28 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Code:
on *:join:*: {
  if ( $nick == $me ) {
    var %nicks = 1
    while ( %nicks <= $nick($chan,0) ) {
      userhost $nick($chan,%nicks)
      inc %nicks
    }
  }
  else {
    userhost $nick
  }
}


I honestly can't figure what's wrong here. I've tried like.. everything. Even running it in a seperate alias. After debugging it, it would seem that it only loops once, not all the times it's supposed to.

Any ideas?

Thanks.


GamerzWoW
The Official GamerzPlanet WoW Server
Re: on JOIN and a while loop. [Re: XTZGZoReX] #193137 15/01/08 01:15 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

Why not just use /who ?

Code:

on *:JOIN:#: {
  if ($nick == $me) who #
}


Also, you don't need to to a /userhost on each nick that joins after you because the server sends their address when they join so they're automatically added to the IAL if it's enabled. As far as your while loop goes...

Code:

on *:JOIN:#: {
  if ($nick == $me) {
    var %nicks = 1
    while ($nick($chan,%nicks) != $null) {
      .timer 1 %i userhost $v1
      inc %nicks
    }
  }
  else userhost $nick
}



~ Edit ~
I assumed you were just filling and updating the IAL, my apologies if I was incorrect.

~ Edit ~
Correction.


Last edited by RoCk; 15/01/08 01:41 PM.
Re: on JOIN and a while loop. [Re: RoCk] #193138 15/01/08 01:23 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
I see. Alright, I'll just do it when I, myself, join. But honestly, I got kind of frustrated over why mIRC won't do this thing.

So, a person on IRC helped me a lot with testing it out, and we came to this conclusion:

Quote:
0,10 0,12 11,2 14:11:19 0,12 0,10  12[10Testarossa12] 4
 0,10 0,12 11,2 14:11:23 0,12 0,10  12[10Testarossa12] hmm
 0,10 0,12 11,2 14:11:41 0,12 0,10  12[10Testarossa12] apparently, //say $nick($chan,0) = 4 and in a script, $nick($chan,0) = 1
 0,10 0,12 11,2 14:11:53 0,12 0,10  12[10Testarossa12] var %chans = $nick($chan,0)
 0,10 0,12 11,2 14:11:53 0,12 0,10  12[10Testarossa12] while ( %nicks <= $nick($chan,0) ) {
 0,10 0,12 11,2 14:11:53 0,12 0,10  12[10Testarossa12] userhost $nick($chan,%nicks)
 0,10 0,12 11,2 14:11:53 0,12 0,10  12[10Testarossa12] echo # %nicks %chans
 0,10 0,12 11,2 14:12:00 0,12 0,10  12[10Testarossa12] and i get this:
 0,10 0,12 11,2 14:12:01 0,12 0,10  12[10Testarossa12] 0 1
 0,10 0,12 11,2 14:12:01 0,12 0,10  12[10Testarossa12] 1 1
 0,10 0,12 11,2 14:12:53 0,12 0,10  12[10XTZGZoReX12] Strange

(Sorry for the color codes.)

So, at this point, I just wonder why $nick() returns different values? It seems strange.

Edit: Even more..

Quote:
0,10 0,12 11,2 14:24:05 0,12 0,10  12[10Testarossa12] var %chans $nick(#peace,0)
 0,10 0,12 11,2 14:24:06 0,12 0,10  12[10Testarossa12] gives 1 as well


Edit2:

Quote:


~ Edit ~
I assumed you were just filling and updating the IAL, my apologies if I was incorrect.

I actually were. smile

Last edited by XTZGZoReX; 15/01/08 01:26 PM.

GamerzWoW
The Official GamerzPlanet WoW Server
Re: on JOIN and a while loop. [Re: XTZGZoReX] #193139 15/01/08 01:27 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

I see the error with $nick($chan,0) when you join, sorry I missed that lol, it's because the nicklist isn't filled until after you join, so you would have to put it in an alias and call it with a timer...

Code:

on *:JOIN:#: {
  if ($nick == $me) .timer 1 5 mejoin #
  else userhost $nick
}

alias mejoin {
  var %nicks = 1
  while ($nick($1,%nicks) != $null) {
    .timer 1 %i userhost $v1
    inc %nicks
  }
}



Better yet...

Code:

on *:JOIN:#: {
  if ($nick == $me) set -eu30 $+(%,mejoin.,#) $true
  else userhost $nick
}

raw 366:*: {
  if (!$eval($+(%,mejoin.,$2),2)) return
  unset $+(%,mejoin.,$2)
  var %nicks = 1
  while ($nick($2,%nicks) != $null) {
    .timer 1 %i userhost $v1
    inc %nicks
  }
}



~ Edit ~
Correction.


Re: on JOIN and a while loop. [Re: RoCk] #193140 15/01/08 01:29 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
I see.. Is there no way it could be done inside the event? It's not that I can't use an alias but it's more convenient the other way.

Edit: Oh, I remember that you could call a timer "outside" the script. So, couldn't I use this to do the while loop after the join, so the nicklist is updated?

But meh, I'm fine with it, if it's not possible.

Thanks for the help so far.

Last edited by XTZGZoReX; 15/01/08 01:31 PM.

GamerzWoW
The Official GamerzPlanet WoW Server
Re: on JOIN and a while loop. [Re: XTZGZoReX] #193141 15/01/08 01:47 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

You can't loop through the nicks from inside the JOIN event when you join because mIRC doesn't receive the NAMES reply until after the JOIN event has finished processing, so it will always be only 1 nick, yours. mIRC hasn't yet received the list of the other nicks at that point.

Re: on JOIN and a while loop. [Re: RoCk] #193142 15/01/08 01:53 PM
Joined: Sep 2007
Posts: 65
X
XTZGZoReX Offline OP
Babel fish
OP Offline
Babel fish
X
Joined: Sep 2007
Posts: 65
Well, then your script above won't work either, since the alias is called inside the JOIN event and is finished before the JOIN event finishes.

So.. There doesn't really seem to be any good way to do this, other than calling it manually, after the event.


GamerzWoW
The Official GamerzPlanet WoW Server
Re: on JOIN and a while loop. [Re: XTZGZoReX] #193145 15/01/08 02:34 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

I put a 5 second timer on it, that was the correction. My last one with the raw 366 would probably be the best way to do it automatically aside from just using the /who # method.

Re: on JOIN and a while loop. [Re: RoCk] #193146 15/01/08 02:48 PM
Joined: Oct 2007
Posts: 102
B
bcancer Offline
Vogon poet
Offline
Vogon poet
B
Joined: Oct 2007
Posts: 102
on *:JOIN:#: {
if ($nick == $me) set -eu30 $+(%,mejoin.,#) $true
else userhost $nick
}

raw 366:*: {
if (!$eval($+(%,mejoin.,$2),2)) return
unset $+(%,mejoin.,$2)
var %nicks = 1
while ($nick($2,%nicks) != $null) {
.timer 1 5 %i userhost $v1
inc %nicks
}
}

Re: on JOIN and a while loop. [Re: bcancer] #193151 15/01/08 04:05 PM
Joined: Dec 2002
Posts: 2,016
R
RoCk Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,016

?