mIRC Home    About    Download    Register    News    Help

Print Thread
#121456 27/05/05 10:36 PM
Joined: Jan 2003
Posts: 9
D
dalbng Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jan 2003
Posts: 9
Hey... I need some help with making a script.

Basically, what I need is an alias that i pass 3 arguments to: server name (for example: 'EFnet', 'IRCnet'), a channel name and a nick in that channel. What basically, it should return 'on' if the nick is in that chan on that server, and 'off' if not.

so var %available = $<alias>(EFnet,#channel,someone)
would return 'on' to %available if nick is there, and 'off' if not there.

Now, I've tried making a simple script myself, but I ran into some problems.

scon -at1 if $!network == %net && %nick !ison %chan { writeini <some file> server chan nick off }
scon -at1 if $!network == %net && %nick ison %chan { writeini <some file> server chan nick on }

Now, I used writeini, because I found out that i cannot use "return" in those scon { } brackets. That was weird thing no. 1. The second weird thing is that sometimes it will say in the status window "* /if: insufficient parameters" which also sucks.

So I'm asking the help of the pros in making a whole new working, better alias smile Thanks in advance.

doodle

edit: i'll just clarify again. This is not just to check if the user is on the server, it's to check if it's on the channel on that server. Thansk again smile

Last edited by dalbng; 27/05/05 10:38 PM.
Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
Code:
alias isonnetchan {
  var %i = $scon(0)
  while (%i) {
    scon %i
    dec %i
    if ($1 == $network) &amp;&amp; ($3 ison $2) {
      scon -r
      return $true
    }
  }
  scon -r
  return $false
}


$isonnetchan(network,#channel,nickname) returns $true when nickname is on channel #channel on network network. It will still work if you have joined the same network multiple times.

Joined: Jan 2003
Posts: 9
D
dalbng Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
D
Joined: Jan 2003
Posts: 9
Thanks a lot! You guys do a great job over here wink

Just one more question, if I may: Will this return $false if I'm using $isonnetchan on a channel that *I am not on*?

Because I suspect that 'if' error of the previous script, was from a 'presence check' of a channel I was not in.

Thanks a lot, again! smile

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Yes, it will only return $true if you both are on that channel.

Joined: Apr 2003
Posts: 701
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Apr 2003
Posts: 701
type this somewhere in an editbox:
//if (blah ison #sfgsdfg) echo -a Yes | else echo -a No
So, ison is always $false when you're not on the channel yourself.

I think the problem lies in the lack of brackets combined with %nick or %chan being $null and being parsed before due to the /scon command. This would give: //if $net == $null && blah ison { writeini... }
(a ison b) is valid, (ison) too, but (a ison) and (ison b) are not and give an error.
This is one of the reasons I try to avoid putting in a command in /scon and /scid. Also /timer gives such problems...

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
;NCN(Network,Channel,Nick) : see if a nick is a in channel on a network
;usage $NCN(Network,Channel,Nick)
; result ON    (nick present)
; result OFF   (nick not present)
; result $null (your not in there, or you didnt supply all parameters)
;
alias NCN {
  if (($1) &amp;&amp; ($2) &amp;&amp; ($3)) {
    var %r
    scon -at1 if ( $!network == $1 ) $({,) if ( $!chan( $2 ) ) $({,) if ( $3 ison $2 ) $({,) var $+(%,r) = ON $(},) $(|,) else $({,) var $+(%,r) = OFF $(},) $(},) $(},)
    return %r
  }
}


This works on multiple networks and/or multiple connections to a same network.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
The IF likely fails becase the { } arent there anymore or the lAck or brackets on two conditions, im not sure which.

scon -at1 if $!network == %net && %nick !ison %chan { writeini <some file> server chan nick off }
becomes this command executed on each connected network
if $network == EFnet && someone !ison #channel writeini <some file> server chan nick off

The { } are evaluated in the scon command creation, u need to use $({,) & $(},) and for | $(|,) or $(|) but i always put the comma in


Link Copied to Clipboard