|
Joined: Jan 2009
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2009
Posts: 7 |
In a script I am making, I need to get the $cid associated with a newly opened Status Window. I've tried using on OPEN for this in version 6.21, but I've had no such luck. I am unsure if this feature is present in newer versions. I'd prefer to not use on CONNECT since I need the $cid right when the window is created. So, my question would be: How do I get the $cid of a newly created Status Window? Edit: I spent some more time on the script and thought of a way to do this. I'd still like some tips on achieving this a better way, though. alias server {
server $1-
if ($mid($1,1,1) == -) {
if (m isin $1 || $1 isin n) { isl.add $scon($scon(0)).$cid $2 }
else { isl.add $cid $2 }
}
else { isl.add $cid $1 }
}
Last edited by Timiz0r; 06/04/09 04:55 PM.
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
Well if it's a newly opened status window, what about $scon($scon(0)).cid ?
This will give you the cid of the last connection opened.
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
You can't do that because a new status window can be opened without the use of /server, there is no proper way of detecting a newly opened status window.But a better way would be to use a timer, that check if the number of status window has changed : //.timerserver 0 0 if ( $scon(0) != $!scon(0) ) $({,0) echo -a scon(0) has changed : $!v2 $(|) .timerserver 0 0 $!regsubex($timer(server).com,/(\d+)/,$calc(\1 $!iif($v2 > $!v1 ,+,-) 1)) $(},0) It's not very clear, but I've tested it and it works very well, use /timerserver to stop the timer, and change the echo part with your alias
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jan 2007
Posts: 1,156
Hoopy frood
|
Hoopy frood
Joined: Jan 2007
Posts: 1,156 |
You could keep track of the status windows opened to know if the one you are referencing is new or not.
|
|
|
|
Joined: Jul 2006
Posts: 4,150
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,150 |
That's what I'm doing here, but before knowing if the window is new, I have to catch when a new status is opened. However, I realize with what you said that my code will detect too if a status window is closed, here is an update : //.timerserver 0 0 if ( $scon(0) != $!scon(0) ) $({,0) if ( $!v1 < $!v2) echo -a a new status window has been opened with $!!cid : $!scon($scon(0)) $(|) .timerserver 0 0 $!regsubex($timer(server).com,/(\d+)/,$calc(\1 $!iif($v2 > $!v1 ,+,-) 1)) $(},0)
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Jan 2009
Posts: 7
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: Jan 2009
Posts: 7 |
You can't do that because a new status window can be opened without the use of /server, there is no proper way of detecting a newly opened status window.But a better way would be to use a timer, that check if the number of status window has changed : //.timerserver 0 0 if ( $scon(0) != $!scon(0) ) $({,0) echo -a scon(0) has changed : $!v2 $(|) .timerserver 0 0 $!regsubex($timer(server).com,/(\d+)/,$calc(\1 $!iif($v2 > $!v1 ,+,-) 1)) $(},0) It's not very clear, but I've tested it and it works very well, use /timerserver to stop the timer, and change the echo part with your alias For my intended use of the script in a bot, I prefer the solution I came up with, even though I'd prefer more of an event-based solution. However, the script you provided is very nice and I may use it in other scripts; I appreciate this very much.
|
|
|
|
|