mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#234083 05/10/11 11:35 AM
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
What I do wrong here? - I'm unable to get anything to work - I'm not expert on this scripting but doing the best I could wink

Trying to check if I'm in channel on or not (base on several networks) and if I'm not in channel (due to netsplit or such) - it'll auto join/run commands.

I've tried 2 different ways but no luck.

Code:
/scid $scon(%network1) {
    if ($chan(#chan1).status == joined) { echo @Chan.Status You are in #chan1 }
    else { echo @Chan.Status You are NOT in #chan1 | /join #chan1 }
}

or even this one doesn't work for me

Code:
/scid $scon(%network1) {
    if ($me(#chan1,$me,a)) { echo @Chan.Status You are in #chan1 }
    else { echo @Chan.Status You are NOT in #chan1 | /join #chan1 }
}


Once I got the working code, I plan to run this script on timer every 15-30 mins or so to ensure that i'm in channel all the times.

Thanks

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
/scid or /scon are not statement that use { }, they just change the active connection used during the script, remove these {} from /scid in the first code and try


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Still doesn't work when I remove { and }

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
How are you using these lines? In an alias?
What is the value of %network1? $scon take a number N in parameter, representing the Nth connection.

Last edited by Wims; 05/10/11 02:25 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
code is written in remote not alias

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Ok, if i do this as an example (using ALIAS not REMOTE - Yea, i've changed it over from REMOTE over to ALIAS)

Code:
/CheckChan {
  /scid $scon(%Network1) {
    if ($me ison #chan1) { //echo -a You are in #chan1 }
    else { //echo -a You are not in #chan1 }
    if ($me ison #chan2) { //echo -a You are in #chan2 }
    else { //echo -a You are not in #chan2 }
    if ($me ison #chan3) { //echo -a You are in #chan3 }
    else { //echo -a You are not in #chan3 }
  }
  /scid $scon(%Network2) {
    if ($me ison #chan4) { //echo -a You are in #chan4 }
    else { //echo -a You are not in #chan4 }
    if ($me ison #chan5) { //echo -a You are in #chan5 }
    else { //echo -a You are not in #chan5 }
    if ($me ison #chan6) { //echo -a You are in #chan6 }
    else { //echo -a You are not in #chan6 }
  }
}

%network1 and %network2 has been set in variables using ON LOAD script i've wrote.

Anyway, when I type /CheckChan on Network1, It shows that I'm in #chan1, #chan2, #chan3 but saying that i'm not in #chan4, #chan5 and #chan6 frown

Now, when I do /CheckChan on Network2, it shows that i'm not in #chan1, #chan2, #chan3 but showing that i'm #chan4, #chan5 and #chan6! frown

Seems that /scid $scon(%Network1) doesn't help at all? - Removing that does not help too.

Any solution please? - My scripting isn't great and never will be :p - it's the only language I kinda understand a little.

I've tested on both mIRC 7.19 and 6.34 but no luck frown

(My english ain't great so hopefully someone can come up with a solution?)

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
Quote:
%network1 and %network2 has been set in variables using ON LOAD script i've wrote.
Ok, but I need to know what are the values of these variables, I explained that in order for the code to work, they need to be numbers
For example (/ are optional):
Code:
CheckChan {
 scid $scon(1)
 if ($me ison #chan1) { echo -a You are in #chan1 }
 else { echo -a You are not in #chan1 }
 if ($me ison #chan2) { echo -a You are in #chan2 }
 else { echo -a You are not in #chan2 }
 if ($me ison #chan3) { echo -a You are in #chan3 }
 else { echo -a You are not in #chan3 }
 
 scid $scon(2)
 if ($me ison #chan4) { echo -a You are in #chan4 }
 else { echo -a You are not in #chan4 }
 if ($me ison #chan5) { echo -a You are in #chan5 }
 else { echo -a You are not in #chan5 }
 if ($me ison #chan6) { echo -a You are in #chan6 }
 else { echo -a You are not in #chan6 }
}
will work for the first and the second connection (the first and second status window)


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
There has to be a better way, but this is all I can think of at the moment:
Code:
alias checkchan {
  var %n = $scon(0)
  while (%n) {
    if ($scon(%n).network == %network1) {
      var %i = 1, %c = #chan1 #chan2 #chan3
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2) 
        inc %i
      }
    }
    elseif ($scon(%n).network == %network2) {
      var %i = 1, %c = #chan4 #chan5 #chan6
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2) 
        inc %i
      }
    }
    dec %n
  }
}
And basically you do the same thing by adding another elseif statement for another network with their own channels...so on and forth.

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Still doesn't work :s
I'm guessing I'm doing something wrong somewhere! frown

Will keep trying and will post what I've done wrong!

Thanks

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
%network1 1
%network2 27
%network3 30

Originally Posted By: Wims
Quote:
%network1 and %network2 has been set in variables using ON LOAD script i've wrote.
Ok, but I need to know what are the values of these variables, I explained that in order for the code to work, they need to be numbers
For example (/ are optional):
Code:
CheckChan {
 scid $scon(1)
 if ($me ison #chan1) { echo -a You are in #chan1 }
 else { echo -a You are not in #chan1 }
 if ($me ison #chan2) { echo -a You are in #chan2 }
 else { echo -a You are not in #chan2 }
 if ($me ison #chan3) { echo -a You are in #chan3 }
 else { echo -a You are not in #chan3 }
 
 scid $scon(2)
 if ($me ison #chan4) { echo -a You are in #chan4 }
 else { echo -a You are not in #chan4 }
 if ($me ison #chan5) { echo -a You are in #chan5 }
 else { echo -a You are not in #chan5 }
 if ($me ison #chan6) { echo -a You are in #chan6 }
 else { echo -a You are not in #chan6 }
}
will work for the first and the second connection (the first and second status window)

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: colt45
Still doesn't work :s
I'm guessing I'm doing something wrong somewhere! frown
change
Code:
$scon(%n).network
to
Code:
$scon(%n).cid
I thought those variables were network names.

Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
These look like connection id rather than connection number.
If they are connection id, you don't have to use $scon(), use the variable directly


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Yeah like Wims said, you can use something like:
Code:
if ($cid == %network1) {
to make a comparison.

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Ahhh, i'm getting something! laugh

When I type this /checkchan on Network1, it shows that I'm in these channels but saying i'm not in channel for Network2 and Network3.
Quote:
{On Network1}
/checkchan
I'm NOT on #Chan4 <-- Network3
I'm NOT on #Chan3 <-- Network2
I'm ON #Chan2 <-- Network1
I'm ON #Chan1 <-- Network1

BUT when I type /checkchan on Network2, it shows that I'm in that channel on Network2 but not in channel on Network1 AND Network3?!? :s

Quote:
{On Network2}
/checkchan
I'm NOT on #Chan4 <-- Network3
I'm ON #Chan3 <-- Network2
I'm NOT on #Chan2 <-- Network1
I'm NOT on #Chan1 <-- Network1

I've changed all to $scon(%n).cid tho

Something's missing, but will keep trying ...

Thanks

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Anyone know how to fix this?

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
I'm sorry, I couldn't get this to work.

Only works on 1 or other server where I type the command.

This is the exact code I'm using right now (except the channel name).

Code:
alias checkchan {
  var %n = $scon(0)
  while (%n) {
    if ($scon(%n).network == Kwik-Chat) {
      var %i = 1, %c = #channel1 #channel2
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
        inc %i
      }
    }
    elseif ($scon(%n).network == EFNet) {
      var %i = 1, %c = #channel3
      while ($gettok(%c,%i,32)) { var %v1 = $v1
        echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
        inc %i
      }
    }
    dec %n
  }
}


On Kwik-Chat, when I type /checkchan I see this as result
Quote:
I'm ON #channel1
I'm ON #channel2
I'm NOT on #channel3


But, on EFNet, when I type /checkchan I see this as result
Quote:
I'm NOT on #channel1
I'm NOT on #channel2
I'm ON #channel3


Please help,
Thanks

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Use this one and see if it makes any difference:
Code:
alias checkchan {
  var %x = 1
  while ($scon(%x).network) {
    if ($regex($v1,/(Kwit-Chat|EFNet)/i)) {
      if ($regml(1) == EFNET) {
        var %i = 1, %c = #channel3
        while ($gettok(%c,%i,32)) { 
          var %v1 = $v1
          echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
          inc %i
        }
      }
      else {
        var %ii = 1, %cc = #channel1 #channel2
        while ($gettok(%cc,%ii,32)) { 
          var %v1 = $v1
          echo -a I'm $iif($me ison %v1,ON $v2,NOT on $v2)
          inc %ii
        }
      }
    }
    inc %x
  }
}

Joined: Nov 2003
Posts: 101
C
colt45 Offline OP
Vogon poet
OP Offline
Vogon poet
C
Joined: Nov 2003
Posts: 101
Seems to be worse frown

Quote:
I'm NOT on #channel3

Showing only 1 line .. that done on Network1.

Quote:
I'm ON #channel3

Showing only 1 line .. that done on Network2.

I don't want to run that command on every network i'm on.

What I need is to show all channel's result from several network. When I'm not in any of the channel, it'll perform by identify myself before joining channel(s).

I'm guessing it's more advance than I thought? - As I don't want to identify myself and join channel every 5 mins or so? - Hence why i need a better script especially when u have quite a lot of channels/network.

(Sorry if my english isnt clear but I will get a friend to help translate for me if you prefer?)

Thanks

Joined: Jul 2007
Posts: 1,129
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I think I've hit the wall at my end. I'm afraid I cannot be of help to you. I hope somebody else, who has a better approach or idea, can assist you further with the issue at hand. eek

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try this:

Code:
alias checkchan {
  var %c = 1, %t = $scon(0)
  while (%c <= %t) {
    scon %c
    if ($network == network1) {
      echo -a NETWORK: $network
      echo -a I'm $iif($me !ison #chan1,NOT) on $v2
      echo -a I'm $iif($me !ison #chan2,NOT) on $v2
    }
    elseif ($network == network2) {
      echo -a NETWORK: $network
      echo -a I'm $iif($me !ison #chan3,NOT) on $v2
      echo -a I'm $iif($me !ison #chan4,NOT) on $v2
    }
    inc %c
  }
}


This will not display "not on" messages for networks that you are not connected to.

* Note that I know there is some security issue with using scon/scid, but I'm not real clear on what it is. Hopefully someone who understands it can decide if this is safe. smile

EDIT:
Here's another option that would work if you have many networks and channels:
Code:
alias checkchan {
  var %network1 = #chan1 #chan2
  var %network2 = #chan3 #chan4
  var %c = 1, %t = $scon(0)
  while (%c <= %t) {
    scon %c
    if ($($+(%,$network),2)) {
      echo -a NETWORK: $network
      var %cc = 1, %ct = $numtok($($+(%,$network),2),32)
      while (%cc <= %ct) {
        var %chan = $gettok($($+(%,$network),2),%cc,32)
        echo -a I'm $iif($me !ison %chan,NOT) on $v2        
        inc %cc
      }
    }
    inc %c
  }
}


For this one, be sure to change the network variable names to be exactly the same as what $network returns. For example:
var %undernet = #chan1 #chan2
var %efnet = #chan3 #chan4

Last edited by Riamus2; 12/10/11 09:57 PM.

Invision Support
#Invision on irc.irchighway.net
Page 1 of 2 1 2

Link Copied to Clipboard