mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
My scripting is terriable, but how do i write script that check if I'm on a channel on multiple network by using 1 command. i.e.

Network1
#Test1
#Test2

Network2
#Test3
#Test4

So when I type /CheckChannel
It'll check all channels that i'm suppose to be on (from a channellist.txt or something else like that) and will return me wheather i'm in channel or not.

Something like this

#Test1 @ Network1 IN CHANNEL
#Test2 @ Network1 IN CHANNEL
#Test3 @ Network2 NOT IN CHANNEL
#Test4 @ Network2 IN CHANNEL


I am able to get it to work only on 1 network but not multiple network frown

(excuse my poor english, hope you understand what i'm trying to do here)

Joined: Jun 2005
Posts: 127
H
Vogon poet
Offline
Vogon poet
H
Joined: Jun 2005
Posts: 127
Why dont you post what you are currently using so we can work off that.


-- HAMM3R (aka: alhammer)
http://www.HAMM3R.net
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
LOL Sure! - Like I said, my scripting is terriable

Code:
/Check.Channel {
  if ($me !ison #TEST1) { /echo -a Not in #TEST1 }
  else { /echo -a You're in #TEST1 }
  if ($me !ison #TEST2) { /echo -a Not in #TEST2 }
  else { /echo -a You're in #TEST2 }
  if ($me !ison #TEST3) { /echo -a Not in #TEST3 }
  else { /echo -a You're in #TEST3 }
  if ($me !ison #TEST4) { /echo -a Not in #TEST4 }
  else { /echo -a You're in #TEST4 }
}


If i type that on Network 1 - #TEST1 and #TEST2 works but not #TEST3 and #TEST4 because it's on different network - so therefore, it's not detecting it.

Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
/Check.Channel {
if ($me !ison #TEST1) { /echo -a Not in #TEST1 }
else { /echo -a You're in #TEST1 }
if ($me !ison #TEST2) { /echo -a Not in #TEST2 }
else { /echo -a You're in #TEST2 }
scid 2 {
if ($me !ison #TEST3) { /echo -a Not in #TEST3 }
else { /echo -a You're in #TEST3 }
if ($me !ison #TEST4) { /echo -a Not in #TEST4 }
else { /echo -a You're in #TEST4 }
}
}


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Lol, nice one thanks smile

Thanks

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:

if ($me !ison #TEST3) { /echo -a Not in #TEST3 }
else { /echo -a You're in #TEST3 }
if ($me !ison #TEST4) { /echo -a Not in #TEST4 }
else { /echo -a You're in #TEST4 }


<3 $iif

echo -a $iif($me ison #test3,You're,Not) in $v2
echo -a $iif($me ison #test4,You're,Not) in $v2


Gone.
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
What my script really worked? i just took the wildest guess ever without a test or assumption it might work


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I don't know if it worked, I didn't look at that, hehe.

I just changed the if-else structure to use $iif, and shorten it considerably. Not that it's too important, but I thought you might not know $iif smile


Gone.
Joined: Aug 2005
Posts: 1,052
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Aug 2005
Posts: 1,052
nope dont know it?? never used iif what is it? an F with two eyes? LOL


Code:
if $reality > $fiction { set %sanity Sane }
Else { echo -a *voices* }
Joined: Jul 2003
Posts: 655
Fjord artisan
Offline
Fjord artisan
Joined: Jul 2003
Posts: 655
Indeed it works, i was actually suprised scid X {} worked heh, have never used it in that manner myself. Does using that method automatically issue an scid -r when it exists the {}'s? If not i guess its only a costmetic grouping thing. Again i suggest the use of a small net2cid alias rather than hard coding cid's.

Code:
/Check.Channel {
  scid $net2cid(NETWORK1) {
    echo -a $iif($me ison #test1,You're,Not) in $v2
    echo -a $iif($me ison #test2,You're,Not) in $v2
  }
  scid $net2cid(NETWORK2) {
    echo -a $iif($me ison #test3,You're,Not) in $v2
    echo -a $iif($me ison #test4,You're,Not) in $v2
  }
  scid -r
  ; probably redundent / not needed if scid {} does this automtically, but i like to be sure
} 
/net2cid {
  var %x = $scon(0), %y = 1
  while (%y &lt;= %x) {
    if ($scon(%y).network == $1) {
      return $scon(%y)
    }
    inc %y
  }
}


$iif(C,T,F) returns T or F depending on whether the if conditions in C are true or false respectively. Depending on the circumstances this can sometimes be faster than an if-then-else statement, and sometimes slower.


"Allen is having a small problem and needs help adjusting his attitude" - Flutterby
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
What my script really worked? i just took the wildest guess ever without a test or assumption it might work


o.O I took a look at the code properly now, and _no_ that isn't correct usage, although it doesn't harm anything. You cannot "group" the code like you did with { }, it has no effect.

The script parser processes those line of code in descending order, so they all get triggered, braces or not. The braces only have an effect of grouping when used in if/elseif/else and while constructs.

scid -r {
echo -a blah
}
scid -r {
echo -a o.O
}

is just the same as:

scid -r
echo -a blah
scid -r
echo -a blah

On other thing: if something is your wildgest guess ever without testing or assuming etc then it might not be the best idea to post the code. I generally (though not always) test my code before posting.


Gone.

Link Copied to Clipboard