mIRC Homepage
Posted By: Deep3D Auto away script, multi networks - 02/04/10 03:12 PM
Im allways connected to more than 1 network, this script it not that good if you connect to more than 1 network. Cause then you wold be away on one network, and not away on the other one since you would have more idle time on the none than on the other.

So, how to check idle on all connected networks, and if ALL is higher than the %away.system.auto.check then set away on all networks. If one network has under this limit, and all other over then unset away on all networks.

Code:
away.system.auto {
  echo Check
  if (!$away) && ($idle >= %away.system.auto.check) && %away.system.auto == on {
    away Auto away after $duration(%away.system.auto.check,2) of idle
    echo -a Set
  }
  if ($away) && ($idle <= %away.system.auto.check) && %away.system.auto == on {
    away
    echo -a Unset
  }
}
Posted By: DJ_Sol Re: Auto away script, multi networks - 02/04/10 04:27 PM
Code:
alias idle_chk {
var %idl_ = $scon(0)
while (%idl) {
echo -s . $scon(%idl_).network idle time is $scon(%idl_).idle
echo -s . You are $iif(!$scon(%idl_).away,not) away on $scon(%idl_).network .
dec %idl_
}
}


Here is an example checking your idle and away status on every network.
Posted By: Deep3D Re: Auto away script, multi networks - 02/04/10 04:38 PM
Cheers!
Posted By: DJ_Sol Re: Auto away script, multi networks - 02/04/10 07:26 PM
Np. I forgot. In your while loop you can check each channel in that scon.
Code:
while ($scon(%idl_)) {

;make scon id active to check its channels
scon %idl_

;set vars for total channels
var %ch_ = $chan(0), %ch
while (%ch_) {
;set var to save channel name instead of using $chan(%ch_) every time.
%ch = $chan(%ch_)

echo -a . %ch idle: $chan(%ch_).idle
echo -a . %ch away: $chan(%ch_).away

dec %ch_
}


dec %idl_
}
Posted By: Deep3D Re: Auto away script, multi networks - 02/04/10 08:16 PM
it all went into a spinning loop and crached my client.
Posted By: RusselB Re: Auto away script, multi networks - 02/04/10 10:31 PM

Simple away system for multiple networks by RusselB
Posted By: DJ_Sol Re: Auto away script, multi networks - 03/04/10 09:55 AM
It was an example. You would want to put it in the alias.

Code:
alias idle_chk {
var %idl_ = $scon(0)
while (%idl) {
echo -s . $scon(%idl_).network idle time is $scon(%idl_).idle
echo -s . You are $iif(!$scon(%idl_).away,not) away on $scon(%idl_).network .

;make scon id active to check its channels
scon %idl_

;set vars for total channels
var %ch_ = $chan(0), %ch
while (%ch_) {
;set var to save channel name instead of using $chan(%ch_) every time.
%ch = $chan(%ch_)

echo -a . %ch idle: $chan(%ch_).idle
echo -a . %ch away: $chan(%ch_).away

dec %ch_
}

dec %idl_
}
}
Posted By: DJ_Sol Re: Auto away script, multi networks - 03/04/10 05:32 PM
Code:
alias idle_chk {
var %idl_ = $scon(0)
while (%idl_) {
echo -s . $scon(%idl_).network idle time is $scon(%idl_).idle
echo -s . You are $iif(!$scon(%idl_).away,not) away on $scon(%idl_).network .

;make scon id active to check its channels
scon %idl_

;set vars for total channels
var %ch_ = $chan(0), %ch
while (%ch_) {
;set var to save channel name instead of using $chan(%ch_) every time.
%ch = $chan(%ch_)

echo -a . %ch idle: $chan(%ch_).idle
echo -a . %ch away: $chan(%ch_).away

dec %ch_
}

dec %idl_
}
}


It wouldn't let me edit this and I found I named the variable wrong in the while statement. When writign loops there is the chance that you mess up and it start an infinite loop. If this happens press ctrl + Pause/Break.
Posted By: Deep3D Re: Auto away script, multi networks - 04/04/10 02:20 AM
How would you add scon into this? I've got confused of the other.

Code:
away.system.auto {
  if %away.system == off && %away.system.auto == on {
    echo Check
    if (!$away) && ($idle >= %away.system.auto.check) {
      away Auto away after $duration(%away.system.auto.check,2) of idle
      echo -a Set
    }
    if ($away) && ($idle <= %away.system.auto.check) {
      away
      echo -a Unset
    }
  }
}
Posted By: Wims Re: Auto away script, multi networks - 04/04/10 02:30 AM
just use /scon -at1 away.system.auto
Posted By: Deep3D Re: Auto away script, multi networks - 04/04/10 02:38 AM
But then the script dont work how I want it to work.

This set me away on the network Ive been idle on, and not away on the network im active on..

If im active on one network, I dont want to be set away on another network. I have to been idle on all networks before been set away.

If over 30 sec set idle set away.

Ex:
Network1 : Idle 100 sec
Network2 : Idle 2 sec
Network3 : Idle 200 sec

Then dont set away on any network...

but if Network2 is over 30 sec of idle then set away on all networks..
Posted By: Wims Re: Auto away script, multi networks - 04/04/10 02:49 AM
Code:
alias away_sys set -u %autoaw 1 | scon -at1 isautoaw | if (%autoaw) && (!away) scon -at1 away
alias isautoaw if ($idle < 60) set -k %isautoaw 0
This basically put you away on all network if each of your idle time are >= 60 secs, type /away_sys
Posted By: Deep3D Re: Auto away script, multi networks - 04/04/10 03:09 AM
Still if one of the network is under 60 sec it sets the other networks away.

It one network is idle under 60 sec then unset away on all networks.

If all networks is over 60 sec of idlem then set away on all networks.

There is no point of being active on one network, and away on another one.

I really appreciate your help.
Posted By: Wims Re: Auto away script, multi networks - 04/04/10 04:01 AM
Code:
alias away_sys set -u %autoaw 1 | set -u %aw | scon -at1 aw |  if (%autoaw) && (!%aw) scon -at1 away param
alias aw if ($idle < 60) set -k %autoaw 0 | if ($away) set -k %aw 1
This one is tested smile
Posted By: Deep3D Re: Auto away script, multi networks - 04/04/10 04:30 AM
sweet! Works.

Now, when one network is under 60 seconds, unset away on all networks.
Posted By: Wims Re: Auto away script, multi networks - 04/04/10 01:30 PM
Code:
alias away_sys set -u %autoaw 1 | set -u %aw | set -u %naw | scon -at1 aw |  if (%autoaw) && (!%aw) scon -at1 away param | elseif (!%aw) scon -at1 away
alias aw if ($idle < 60) set -k %autoaw 0 | if ($away) set -k %aw 1 | else set -k %naw 1
Not tested but should do it.
Posted By: Deep3D Re: Auto away script, multi networks - 04/04/10 11:20 PM
Sorry, it dont work. The script sets away, but don't turn off if not idle.
Posted By: Wims Re: Auto away script, multi networks - 04/04/10 11:38 PM
a typo sorry :

Code:
alias away_sys set -u %autoaw 1 | set -u %aw | set -u %naw | scon -at1 aw |  if (%autoaw) && (!%aw) scon -at1 away param | elseif (%naw) scon -at1 away
alias aw if ($idle < 60) set -k %autoaw 0 | if ($away) set -k %aw 1 | else set -k %naw 1
Posted By: Deep3D Re: Auto away script, multi networks - 05/04/10 09:43 AM
Still don't work.

Code:
alias away_sys set -u %autoaw 1 | set -u %aw | set -u %naw | scon -at1 aw | if (%autoaw) && (!%aw) scon -at1 away.system.auto | elseif (%naw) scon -at1 away.system.auto
alias aw if ($idle < %away.system.auto.check) set -k %autoaw 0 | if ($away) set -k %aw 1 | else set -k %naw 1


Code:
away.system.auto {
  if %away.system == off && %away.system.auto == on {
    echo Check
    if (!$away) && ($idle >= %away.system.auto.check) {
      away Auto away after $duration(%away.system.auto.check,2) of idle
      echo -a Set $server
    }
    if ($away) && ($idle <= %away.system.auto.check) {
      away
      echo -a Unset $server
    }
  }
}
Posted By: Wims Re: Auto away script, multi networks - 05/04/10 03:06 PM
Why are you using the second alias ? You don't need it :

Code:
alias away_sys set -u %autoaw 1 | set -u %aw | set -u %naw | scon -at1 aw | if (%autoaw) && (!%aw) scon -at1 away Auto away after $duration(%away.system.auto.check,2) of idle | elseif (%naw) && (%aw) scon -at1 away
alias aw if ($idle < %away.system.auto.check) set -k %autoaw 0 | if ($away) set -k %aw 1 | else set -k %naw 1
This is tested
Posted By: Deep3D Re: Auto away script, multi networks - 06/04/10 05:45 PM
It still dont turn off away if Im active. Strange if it works for you and not me.
Posted By: Wims Re: Auto away script, multi networks - 06/04/10 08:13 PM
How are you testing it ? I've just replaced your %var with a number like 15, used something like /timera 0 2 away_sys and typed something in a channel, ~15 seconds later, $idle was > 15 on each network so it put me away, when I broke my idle again, it put me back etc...

I think the problem is that you need to check 'cancel away on activity' in mIRC option (alt + o > IRC > option)
Posted By: Deep3D Re: Auto away script, multi networks - 06/04/10 08:25 PM
This is how I test it: I have /timer 0 10 away_sys

And I set the %away.system.auto.check 60

The part that sets me away works great. But not set me back, I find it strange.

Cancel away on activity is unchecked, I dont use it. Then the auto away and the rest of my away system wont work how Id like it to work.
Posted By: DJ_Sol Re: Auto away script, multi networks - 06/04/10 09:00 PM
If you are using identifiers like $away and $idle or using them as props you probably need mirc to cancel your away status on activity. Unless you want to write your code to do this.
Posted By: Wims Re: Auto away script, multi networks - 06/04/10 09:06 PM
What I'm saying is that you need this to be checked for my script to work.
I'm only checking if the value of $away is $false on one server to consider you're not away anymore, that's why you need something to unset your away status on activity, either the mirc option (simple), or a scripted solution but really, no need to use a script when mirc purely do what you want.
Quote:

Then the auto away and the rest of my away system wont work how Id like it to work.
Is your away system not supposed to be the script I'm giving you, that need this option to be checked ?
Posted By: Deep3D Re: Auto away script, multi networks - 07/04/10 03:12 AM
The code you wrote is a part of my away system. smile

Code:
away_sys {
  if %away.system == off && %away.system.auto == on {
    set -u %autoaw 1 | set -u %aw | set -u %naw | scon -at1 aw
    if (!$away) && (%autoaw) && (!%aw) {
      scon -at1 away Auto away after $duration(%away.system.auto.check,2) of idle
      echo.mode You have been automatically marked as being away after $duration(%away.system.auto.check,2) of idle
      titlebar - [Away: Auto]
    }
    if (!%autoaw) && (%aw) {
      scon -at1 away
      echo.mode Away has automatically been turned off
      titlebar
    }
  }
}

This is how I ended up. :)

aw {
  if ($idle < %away.system.auto.check) { set -k %autoaw 0 | if ($away) set -k %aw 1 | else set -k %naw 1 }
  if ($idle > %away.system.auto.check) { set -k %autoaw 1 | if ($away) set -k %aw 0 | else set -k %naw 0 }
}
Posted By: Wims Re: Auto away script, multi networks - 07/04/10 03:24 PM
Well, there is a big difference between what was my code and how you used it, I'm not sure why you modified it this way if you don't know what it does.
If you don't want to check the mIRC option, that's your problem, but my code will not work without it.Now it's up to you, I won't spend more time on this.
Posted By: chacha Re: Auto away script, multi networks - 07/04/10 08:29 PM
Originally Posted By: Deep3D
set -u %autoaw 1

set -u <- what??
/help /set

set -uN
Posted By: Horstl Re: Auto away script, multi networks - 07/04/10 08:52 PM
/set -u unsets the variable after the routine has finished. It's interchangeable with /var in many cases, but not all cases.
A routine may for example be an alias calling several other aliases - you could access a local variable only within each alias itself. It's also handy in $submenu and "begin": you can access the /set -u global variable in all the other $1 values; the var will not unset until the complete submenu was processed.

Edit:
Originally Posted By: help
[...] If you specify a zero for N, the variable is unset when the script finishes.
So he could have put: -u0 smile
Posted By: chacha Re: Auto away script, multi networks - 07/04/10 08:59 PM
ok smile
Posted By: Deep3D Re: Auto away script, multi networks - 08/04/10 11:54 AM
I modify your code into how I'd like it. And It works perfect, and Im greatfull that you spend your time on it. If you didn't I wouldn't have the script. So thank you.

I didn't want to use the mirc option because how the rest of my away system works.

Can you guys see any problem with how I edit the script?
Posted By: Wims Re: Auto away script, multi networks - 08/04/10 03:44 PM
my 'aw' alias was written to work in an specific way : with the mirc option 'cancel away on activity', if you don't want to use this option, you have to write a long script that will do the 'cancel away on activity' part.
If you have a problem with this then there's probably something wrong somewhere
Posted By: Deep3D Re: Auto away script, multi networks - 09/04/10 12:51 AM
Well, I made it work without mirc option 'cancel away on activity'.

In my away system if you get auto away it now cancel away on activity, and not with mirc option, it's scripted. If I choose to set myself away with the Away System I dont want cancel away on activity.

BUT, there is 1 fault in the script (anyone tell me if they see any others).
If I get disconnected from server without using /quit (in this case: [10053] Software caused connection abort) and when the script connects again it sets me away 10 +/- times and then everything is ok (problem is just while reconnecting). Its annoying to get all the echos and the fact that there is actually a fault in the script. smile

Code:
away.system.auto {
  if %away.system == off && %away.system.auto == on {
    set -u %autoaw 1 | set -u %aw | set -u %naw | scon -at1 aw
    if (!$away) && (%autoaw) && (!%aw) {
      scon -at1 away %away.system.auto.message
      echo.mode You have been automatically marked as being away after $duration(%away.system.auto.check,2) of idle
      titlebar - [Away: Auto]
    }
    if (!%autoaw) && (%aw) {
      scon -at1 away
      echo.mode Away has automatically been turned off
      titlebar
    }
  }
}


Code:
aw {
  if ($idle < %away.system.auto.check) { set -k %autoaw 0 | if ($away) set -k %aw 1 | else set -k %naw 1 }
  if ($idle > %away.system.auto.check) { set -k %autoaw 1 | if ($away) set -k %aw 0 | else set -k %naw 0 }
}
Posted By: Deep3D Re: Auto away script, multi networks - 10/04/10 05:56 AM
no? smile
Posted By: RusselB Re: Auto away script, multi networks - 10/04/10 08:38 AM
No errors that I can see, but here's a suggestion
Code:
aw {
  set -k %autoaw $iif($idle < %away.system.auto.check,0,1)
  if $away {
    set -k $iif(%autoaw,%aw,%naw) 1
    set -k $iif(%autoaw,%naw,%aw) 0
  }
}

Posted By: Deep3D Re: Auto away script, multi networks - 10/04/10 04:23 PM
Thank you. smile (EDIT: Your suggestion did not turn off away when I typed in channel)

As I explained earlier.

If I get disconnected (not on purpose), and when reconnecting script sets me away +/- 10 times in the connecting progress, how to stop that? It's just so I dont get annoying echos.

Want me to write more in detail or is this understandable?
Posted By: DJ_Sol Re: Auto away script, multi networks - 10/04/10 05:27 PM
If you don't use mirc's internal system to turn off away then you are douing it with scripted events. Show your events.
Posted By: Deep3D Re: Auto away script, multi networks - 11/04/10 05:08 AM
If events is code I have posted it twice above.
Posted By: chacha Re: Auto away script, multi networks - 11/04/10 11:59 AM
to auto return you have to do it with ON INPUT event something like
Code:
on *:input:*:if (away condition) <return code>
Posted By: bwuser Re: Auto away script, multi networks - 15/04/10 07:07 PM
Originally Posted By: chacha
to auto return you have to do it with ON INPUT event something like
Code:
on *:input:*:if (away condition) <return code>

not really, mIRC resets $idle counter to 0 before triggering on INPUT, so original version with comparisons will work
Posted By: chacha Re: Auto away script, multi networks - 15/04/10 07:30 PM
may be i misspoke i wanted to say like this
Code:
on *:input:*:{
  if $away {
    away
    ;if used /tnick NickAw
    nick $anick
    ame back
  }
}
Posted By: FroggieDaFrog Re: Auto away script, multi networks - 18/04/10 04:44 PM
Here's How I did it -shrugg-

Code:
alias away.system.auto {
  scon -a if (%away.system.auto == on && $idle >= %away.system.auto.check) inc %away.system.check.idle
  var %x = $scon(%x)
  while (%x) {
    scon %x if ($away) && (%away.system.check.idle != $scon(0)) { away $chr(124) echo -a unset }
    scon %x if (!$away) && (%away.system.check.idle == $scon(0)) { away Auto away after $duration(%away.system.auto.check,2) of idle $chr(124) echo -a unset }
    dec %x
  }
  unset %away.system.check.idle
}

Posted By: FroggieDaFrog Re: Auto away script, multi networks - 19/04/10 02:08 AM
Ok, the first post I did was basically an away check across all networks and what not but didn't account for you being disconnected. This one accounts for that, and has the events to start/stop the checks

Code:
on *:INPUT:#,?:{ away.system.auto }
on *:CONNECT:{ if (!$timer(.Auto.Away) { .timer -oi .Auto.Away 0 1 away.system.auto } }

alias away.system.auto {
  var %x = $scon(0)
  while ($scon(%x)) {
    if ($scon(%x).status == Connected) { inc %Away.Connection.Check }
    dec %x
  }
  if (!%Away.Connection.Check) { 
    .timer.Auto.Away off 
  }
  else {
    if (!$timer(.Auto.Away)) { .timer -oi .Auto.Away 0 1 away.system.auto }
    scon -a if ($status == Connected && %away.system.auto == on && $idle >= %away.system.auto.check) inc %away.system.check.idle
    var %x = $scon(%x)
    while (%x) {
      scon %x if ($status == Connected) && ($away) && (%away.system.check.idle != %Away.Connection.Check) { away $chr(124) echo -a unset }
      scon %x if ($status == Connected) && (!$away) && (%away.system.check.idle == %Away.Connection.Check) { away Auto away after $duration(%away.system.auto.check,2) of idle $chr(124) echo -a unset }
      dec %x
    }
  }
  unset %Away.Connection.Check
  unset %away.system.check.idle
}
Posted By: chacha Re: Auto away script, multi networks - 19/04/10 10:32 AM
so every on input that will execute the alias? too bad!
Posted By: FroggieDaFrog Re: Auto away script, multi networks - 19/04/10 12:49 PM
Yes on any input to channel or query it will activate. Considering most ppl don't have more than 3-5 active connections the loops shouldn't be an issue

but, I see you're point:
Code:
on *:INPUT:#,?:{
  scon -a if ($status == connected && $away) { away }
}
Posted By: Janperi Re: Auto away script, multi networks - 15/02/11 07:41 AM
Where i set auto away time in this script?
© mIRC Discussion Forums