mIRC Home    About    Download    Register    News    Help

Print Thread
#164588 14/11/06 12:34 AM
Joined: Jul 2003
Posts: 37
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Jul 2003
Posts: 37
Hi all,

I'm having a problem with my away script and multi-servers.

If I am not fully connected to a server the script locks up.

Code:
 
alias awaystart { 
  unset %opaway*
  W.Var Away Away Yes
  .timeraaway off
  var %tempaway 1
  while (%tempaway <= $scon(0)) {
    scon %tempaway
    if (($chan(0) != 0) && ($server != $null)) {
      echo -a $timestamp $GR(You are now marked as Away on $network)
      ;      .raw away $R.Var(Away,CReason)
      if ($R.Var(Away,Nick) == On) { 
        W.Var Away Normal $me
        if ($R.Var(NickKeeper,Power) == on) {
          W.Var NickKeeper Power off
          timer 1 10 W.Var NickKeeper Power on 
        }
        nick $R.Var(Away,Nickname)
      }
      inc %tempaway
      if ($R.Var(Away,Silent) != On) { amsg $gr(I am now away. Time:) %spc $+ $time(h:nn tt) $gr(Reason:) %spc $+ $R.Var(Away,CReason) | .timeraway 0 [ [ $R.Var(Away,ADelay) ] ] awayrun }
      W.Var Away StartTime $ctime
    }
  }
  scon 1
  if ($dialog(awaysys) != $null) { did -b $dname 8 | did -e $dname 9 }
  .timertbar -o 0 1 tbar
}

 


The problem appears to be where I use
if (($chan(0) != 0) && ($server != $null)) {
as a check, as that's where it locks up.

Can anyone give me some advice on a way around this problem please?

Thanks in advance
Palz

Joined: Oct 2003
Posts: 313
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 313
You only inc %tempvar inside that if (). If the condition is false, it will never never reach $scon(0)!


Sais
Joined: Jul 2003
Posts: 37
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Jul 2003
Posts: 37
dang, now how the hell did I miss spotting that? I've checked this code a million times confused

Thanks a lot Sais, replaced it with

Code:
  
  var %tempaway 0
  while (%tempaway <= $scon(0)) {
    inc %tempaway
    scon %tempaway


and should be end of problem grin

Joined: Oct 2003
Posts: 313
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 313
Done it plenty of times myself, and spent ages trying to track it down laugh

When you said "hangs at this line", it just made me wonder what you meant - the one thing I guessed at was an infinite loop. From there it was child's play smile


Sais

Link Copied to Clipboard