on ^*:quit:{
  if ($chr(126) isin $nick) { return }
  d.whois $nick
  if (($3 == $null) && ($chr(46) isin $1) && ($chr(46) isin $2) && (%netsplit [ $+ [ $iNetwork ] ] != on) && (irc. isin $1-)) {
    aecho 4Netsplit Detected. $c(1) $+ « $+ $c(2) $+ $1- $+ $c(1) $+ » $c(2) $+ $ts | if ($r.set(Invision,SndOpt25) == On) { SoundQ $shortfn($mircdir) $+ $r.glob(Themes,Sound27) }
    set %netsplit [ $+ [ $iNetwork ] ] on
    set %chkSplit [ $+ [ $iNetwork ] ] 1    
    .timer -o 1 50 checksplit
    .timer -o 1 60 unset %netsplit [ $+ [ $iNetwork ] ]
    .timer -o 1 300 unset %chkSplit [ $+ [ $iNetwork ] ]
  }
  if  (%netsplit [ $+ [ $iNetwork ] ] != on) {
    if $nick == $r.set(Personal.Info,Nick) && $r.set(Invision,KeepNick) == On { nick $r.set(Personal.Info,Nick) }
    if ($r.set(DCC.Watch,Status) == On) {
      .timer -o 1 0 watchclose $nick q
      .timer -o 1 0 watchqueues $nick q
    }
    if $r.set(Invision,Seen) == On && (($level($fulladdress) >= 15) || ($r.set(Invision,SeenTrack) == All)) { 
      wseen $remove($nick,$chr(123),$chr(125),$chr(94),$chr(91),$chr(93)) QUIT $adate $ctime $1-
    }
  }
  If ($nick != $me) { .timer 1 0 gainops }
  if $mevents(quits) == 0 || $mevents(quits) == 2 {
    ;var %ct = 1
    ;while (%ct <= $chan(0)) {
    incomwith $colour(quit) $nick $ts $nick « $+ $gettok($fulladdress,2-,33) $+ » has Quit iRC $iif($len($1-) > 6, $chr(40)) $+ $iif($left($1-,5) == QUIT:,$right($1-,-6),$1-) $+  $+ $color(quit) $+ $iif($len($1-) > 6, $chr(41)) 
    ;  inc %ct 1
    ;  continue
    ;}
  }
  if $mevents(quits) == 1 || $mevents(quits) == 2 {
    echo $color(quit) -s $ts $nick « $+ $gettok($fulladdress,2-,33) $+ » has Quit iRC $iif($len($1-) > 6, $chr(40)) $+ $iif($left($1-,5) == QUIT:,$right($1-,-6),$1-) $+  $+ $color(quit) $+ $iif($len($1-) > 6, $chr(41))
  }
  halt
}
alias watchclose {
  if $1 != $null {
    if $DCCwatchchk($1) == $false { 
      if (($isend($1) != $null) || ($fserv($1) != $null)) { 
        .timerDCCW $+ $iNetwork $+ $1 -o 1 $iif($2 == P,60,600) close -fs $1 
        set %DCCW [ $+ [ $1 ] ] [ $+ [ $iNetwork ] ] 1 
        .timer -o 1 $iif($2 == P,65,185) unset %DCCW [ $+ [ $1 ] ]  [ $+ [ $iNetwork ] ] 
        aecho DCC Sends to $1 will be stopped in $iif($2 == p,1,10) $+ min. if they don't return to the channel. 
        if $2 == p { .msg $1 Your DCC Sends will be terminated unless you return to the channel within 1 min. }
      }
    }
  }
}
alias watchqueues {
  if $1 != $null {
    if $DCCwatchchk($1) == $false {
      if $Queue.nick($1) >= 1 || $PQueue.nick($1) >= 1 {
        .timerDCCQ $+ $1 $+ $inetwork -o 1 $iif($2 == P,58,598) ClrQueues $1 
        set %DCCQ [ $+ [ $iNetwork ] ] [ $+ [ $1 ] ] 1 
        .timer -o 1 $iif($2 == P,65,185) unset %DCCQ [ $+ [ $iNetwork ] ] [ $+ [ $1 ] ]
        aecho DCC Queues for $1 will be deleted in $iif($2 == p,1,10) $+ min. if they don't return to the channel. 
        if $2 == p { .msg $1 Your DCC Queues will be removed unless you return to the channel within 1 min. }
      }
    }
  }
}
; ################################################
; ##                                    PART
; ################################################
on ^*:part:#:{
  if (%mfludjp [ $+ [ $chan ] ] == 1) { Halt }
  mflud join $chan
  if $comchan($nick,0) == 0 { d.whois $nick }
  if ($r.set(DCC.Watch,Status) == On) {
    .timer -o 1 0 watchclose $nick p
    .timer -o 1 0 watchqueues $nick p
  }
  if ($nick != $me) {
    if ($1- != $null) {
      if $mevents(parts) == 0 { 
        echo $colour(part) $chan $ts $nick ( $+ $address $+ ) has parted. ( $+ $1- $+ ) $bracket($calc($nick($chan,0,a) - 1),$iif($calc($nick($chan,0,a) - 1) == 1,person,people)) 
      }
      if $mevents(parts) == 1 { 
        echo $colour(part) -s $ts $nick ( $+ $address $+ ) has parted $chan $+ . ( $+ $1- $+ ) $bracket($calc($nick($chan,0,a) - 1),$iif($calc($nick($chan,0,a) - 1) == 1,person,people)) 
      }
    }
    else { 
      if $mevents(parts) == 0 { 
        echo $colour(part) $chan $ts $nick ( $+ $address $+ ) has parted. $bracket($calc($nick($chan,0,a) - 1),$iif($calc($nick($chan,0,a) - 1) == 1,person,people)) 
      }
      if $mevents(parts) == 1 { 
        echo $colour(part) -s $ts $nick ( $+ $address $+ ) has parted $chan $+ . $bracket($calc($nick($chan,0,a) - 1),$iif($calc($nick($chan,0,a) - 1) == 1,person,people)) 
      }
    }
  }
  if $r.set(Invision,Seen) == On && (($level($fulladdress) >= 15) || ($r.set(Invision,SeenTrack) == All)) { 
    wseen $remove($nick,$chr(123),$chr(125),$chr(94),$chr(91),$chr(93)) PART $adate $ctime $chan
  }
  if ($nick != $me) { .timer 1 0 gainops }
  if $r.set(AutoInform,Status) == On {
    if $r.set(AutoInform,Part) == On && $istok($r.set(AutoInform,Channels),$chan,44) { 
      if $r.set(AutoInform,Excludes) == On && $level($address($nick,5)) >= 15 { goto jump }
      if $r.set(AutoInform,Via) == Msg {
        if $r.set(AutoInform,Msg) != $null { .msg $nick [ [ $r.set(AutoInform,Msg) ] ] }
      }
      else {
        if $r.set(AutoInform,Msg) != $null { .notice $nick [ [ $r.set(AutoInform,Msg) ] ] }
      } 
      :jump
    }
  }
  haltdef
}
; ################################################
; ##                                    JOIN
; ################################################
on ^*:join:#:{
  var %curNetwork = $iNetwork
  if (%mfludjp [ $+ [ $chan ] ] == 1) { Halt }
  mflud join $chan
  if ($r.set(Invision,ChanScan) == On) {
    if ($chr(126) !isin $nick) {
      if (%whoisjoinflag [ $+ [ %curNetwork ] ] <= 3) || (%whoisjoinflag [ $+ [ %curNetwork ] ] == $null) {
        inc %whoisjoinflag [ $+ [ %curNetwork ] ] 1
        .timerwjf $+ %curNetwork -o 1 2 unset %whoisjoinflag [ $+ [ %curNetwork ] ]
        if ($r.whois($nick) == $null) && ($nick != $me) {
          w.whois $nick 1
          whois $nick
          .timer 1 $iif((%chanscandly isnum),%chanscandly,2) if $!remove($ial( $+ [ $nick ] $+ ).mark, [ $chan ] ) != $!null $chr(123) echo $color(info) [ $chan ] $!ts < $+ [ $nick ] $+ > is also in channels $!bracket($remove($ial( $+ [ $nick ] $+ ).mark, [ $chan ] )) $chr(125)
        }
      }
    }
  }
  if ($nick != $me) && (%DCCW [ $+ [ $nick ] ] [ $+ [ %curNetwork ] ] == 1) { 
    .timerDCCW $+ $nick $+ %curNetwork off 
    unset %DCCW [ $+ [ $nick ] ] [ $+ [ %curNetwork ] ]
    aecho $c(2) $+ $nick $c(1) $+ returned to the channel in time enough not to loose their sends.
    .timer 1 0 .notice $nick $c(1) $+ You returned to the channel in time enough not to loose your sends.
  }
  if ($nick != $me) && (%DCCQ [ $+ [ %curNetwork ] ] [ $+ [ $nick ] ] == 1) { 
    .timerDCCQ $+ $nick $+ %curNetwork off 
    unset %DCCQ [ $+ [ %curNetwork ] ] [ $+ [ $nick ] ]
    aecho $c(2) $+ $nick $c(1) $+ returned to the channel in time enough not to loose their Queues.
    .timer 1 0 .notice $nick $c(1) $+ You returned to the channel in time enough not to loose your Queues.
  }
  if ($nick == $me) { 
    echo $chan $tag $c(1) $+ Successfully joined $c(2) $+ $chan $c(1) $+ on $c(2) $+ $time(dddd) $c(1) $+ at $c(2) $+ $time(h:nntt) 
    .timer 1 1 pladjsetup $chan
    if ($r.glob(Nick.Colors,ForceUL) == On) || ($r.set(Invision,ForceIAL) == On) { .timer 1 $calc($chan(0) * 3) .who $chan } 
    w.set Invision RecentChans $addtok($r.set(Invision,RecentChans),$chan,44)
    :jmp1
    if ($numtok($r.set(Invision,RecentChans),44) >= 10) { w.set Invision RecentChans $deltok($r.set(Invision,RecentChans),1,44) | goto jmp1 }
    if ($r.set(Invision,SndOpt32) == On) { .timer 1 1 SoundQ $shortfn($mircdir) $+ $r.glob(Themes,Sound35) } 
    if ($istok($r.cf(ChanOps,Channels),$chan,44)) {   
      .timer 1 12 chmodeEnforce $chan
    } 
  }
  else {
    if ($ialchan($wildsite,$chan,0) > 1) {
      var %clone.w-c = 0
      :start
      inc %clone.w-c
      if ($ialchan($wildsite,$chan,%clone.w-c) == $null) {
        if ($mevents(joins) == 0) {
          echo $colour(join) $chan $ts $nick ( $+ $address $+ ) has joined but is a 4Clone of $gettok(%clone.w-m,1-,38)  $+ $colour(join) $bracket($nick($chan,0,a),$iif($nick($chan,0,a) == 1,person,people))
        }
        if ($mevents(joins) == 1) {
          echo $colour(join) -s $ts $nick ( $+ $address $+ ) has joined $chan but is a 4Clone of $gettok(%clone.w-m,1-,38)  $+ $colour(join) $bracket($nick($chan,0,a),$iif($nick($chan,0,a) == 1,person,people))
        }
        unset %clone.w-c %clone.w-m
      }
      elseif ($ialchan($wildsite,$chan,%clone.w-c).nick == $nick) { goto start }
      else { if ($len(%clone.w-m) <= 500) { var %clone.w-m = %clone.w-m $ialchan($wildsite,$chan,%clone.w-c).nick & } | goto start }
    }
    else { 
      if ($mevents(joins) == 0) {
        echo $colour(join) $chan $ts $nick ( $+ $address $+ ) has joined. $bracket($nick($chan,0,a),$iif($nick($chan,0,a) == 1,person,people)) 
      }
      if ($mevents(joins) == 1) {
        echo $colour(join) -s $ts $nick ( $+ $address $+ ) has joined $chan. $bracket($nick($chan,0,a),$iif($nick($chan,0,a) == 1,person,people)) 
      }
    }
  }
  if ($r.set(Messenger,Status) == On) {
    if ($r.set(Messenger,Mode) == Join) {
      if ($CheckPending($fulladdress)) {
        .msg $nick $c(1) $+ I have $c(2) $+ $messagect($fulladdress) $c(1) $+ message(s) waiting for you. Please message me back $c(2) $+ !getmsg $c(1) $+ command to receive. $ilogo 
      }
    }
  }
  if ($level($fulladdress) == 5) { if ($me isop $chan) { mode $chan -o+b $nick $mask($fulladdress,3) | kick $chan $nick $isset($r.shit($replace($address($nick,3),^,$chr(61))),No Reason Specified) (Shitlisted) | aecho $nick $bracket($address) is going to be removed from $c(2) $+ $chan $+ $c(1) $+ . $bracket(Shitlisted) } }
  if ($gettok($r.greet($nick),1,32) == $nick) && ($r.set(Auto.Greet,Status) == On) && (($istok($r.set(Auto.Greet,Channels),$chan,44) == $true) || ($r.set(Auto.Greet,Channels) == All) || ($r.set(Auto.Greet,Channels) == $null)) { msg $chan $c(2) $+ «  $nick  » $c(1) $+ -  $+ $gettok($r.greet($nick),2-,32) }
  if ($r.set(Invision,Seen) == On) && (($level($address($nick,5)) >= 15) || ($r.set(Invision,SeenTrack) == All)) { 
    wseen $remove($nick,$chr(123),$chr(125),$chr(94),$chr(91),$chr(93)) JOIN $adate $ctime $chan
  }
  if ($me isop $chan) {
    if ($ufchk($fulladdress,+v,$chan)) { .timer 1 $rand(1,20) if $nick !isvo $chan { mode $chan +v $nick } }
    if ($ufchk($fulladdress,+o,$chan)) { .timer 1 $rand(1,20) if $nick !isop $chan { mode $chan +o $nick } }
  }
  if ($r.set(AutoInform,Status) == On) {
    if ($r.set(AutoInform,Join) == On) && ($istok($r.set(AutoInform,Channels),$chan,44)) { 
      if ($r.set(AutoInform,Excludes) == On) && ($level($address($nick,5)) >= 15) { goto jump }
      if ($r.set(AutoInform,Via) == Msg) {
        if ($r.set(AutoInform,Msg) != $null) { .msg $nick [ [ $r.set(AutoInform,Msg) ] ] }
      }
      else {
        if ($r.set(AutoInform,Msg) != $null) { .notice $nick [ [ $r.set(AutoInform,Msg) ] ] }
      } 
      :jump
    }
  }
  .timerjj $+ %curNetwork -o 1 8 unset %jj [ $+ [ %curNetwork ] ]
  set %jj [ $+ [ %curNetwork ] ] 1
  if ($nick != $me) { if ($r.set(Enforcer,Status) == On) { if ($istok($r.set(Enforcer,Channels),$chan,44)) { .timer $+ Enforce $+ $nick $+ %curNetwork 1 $r.set(Enforcer,Delay) Enforcer $nick } } }
  haltdef
}
; ################################################
; ##                                    KICK
; ################################################
on ^*:kick:#:{
  if ($r.set(DCC.Watch,Status) == On) && (($isend($knick) != $null) || ($fserv($knick) != $null)) && (($istok($r.set(DCC.Watch,Channels),$chan,44) == $true) || ($r.set(DCC.Watch,Channels) == All) || ($r.set(DCC.Watch,Channels) == $null)) { close -fs $knick | .notice $knick $c(1) $+ All of your DCC connections with me have been halted because you left one of the following channels. $bracket($iif($r.set(DCC.Watch,Channels) == $null || $r.set(DCC.Watch,Channels) == All,Any channel I am on,$r.set(DCC.Watch,Channels))) | aecho $knick lost all of their DCC connections because they left $c(2) $+ $chan $+ $c(1) $+ . }
  if ($knick == $me) { 
    if ($r.set(Invision,SndOpt4) == On) { 
      SoundQ $shortfn($mircdir) $+ $r.glob(Themes,Sound4) 
      if ($me ison $chan) { 
        echo $colour(kick) $chan $ts You were kicked by $nick ( $+ $clradj($1-) $+ ) 
      } 
      echo $colour(kick) -s $ts You were kicked from $chan by $nick ( $+ $clradj($1-) $+ ) 
    }
    else { 
      if $mevents(kicks) == 0 {
        echo $colour(kick) $chan $ts $knick was kicked by $nick ( $+ $clradj($1-) $+ ) 
      }
      if $mevents(kicks) == 1 {
        echo $colour(kick) -s $ts $knick was kicked from $chan by $nick ( $+ $clradj($1-) $+ ) 
      }
    }
    haltdef
  } 
}
; ################################################
; ##                                    CONNECT
; ################################################
on *:connect:{ .timer 1 1 connroutine }
; ################################################
; ##                                    DISCONNECT
; ################################################
on *:disconnect:{
  if $scon(0) == 0 { if $exists( [ $r.glob(Themes,TrayIcon1) ] ) { .tray -i0 $r.glob(Themes,TrayIcon1) } | else { .tray -ix } }
  if ($window(@Ports) != $null) { window -c @Ports }
  ; .timer 1 0 tbar 
  if ($r.set(Invision,SndOpt3) == On) { SoundQ $shortfn($mircdir) $+ $r.glob(Themes,Sound3) }
  .timerAlways_Home $+ $iNetwork off
  .timerKeep_Nick $+ $iNetwork off
  if $scon(0) == 0 {
    .timerevery3 off 
    .titlebar - Invision 2.0 - http://www.i-n-v-i-s-i-o-n.com 
    .addonunload dalnet.mrc
  }
  if (%Connected [ $+ [ $server ] ] != 1) { aecho Settings Not Saved | halt }
  if %impscript != i2 && %spacesindir != 1 { saveallsettings |  freetables | aecho Settings Saved }
  ; unset %SCIDnet [ $+ [ $cid ] ] 
}
; ################################################
; ##                                    STARTUP
; ################################################
on 1:start:{
  if (%iDebug) echo -s 13Entered STARTUP
  unset %startcheck %fservenicks %chatserv* %lastct* %ojk* %LFL* %LFN* %tmp* %flud* %NOSSEND* %DCCallow* %Sessionlevel* %SCIDnet*
  if (%iDebug) echo -s 13Unset Variables
  .timerstartchk $+ $iNetwork -io 1 1 if $chr(37) $+ startcheck != 1 $chr(123) .timer -io 1 60 exit $chr(124) dialog -m booterror booterror $chr(125) 
  if (%iDebug) echo -s 13Did Boot Error Timer 
  if $r.mirc(Invision,Shutdown) != 1  && $r.mirc(Invision,Rebooting) != 1 { 
    .timerAutoClosedTI $+ $iNetwork -io 1 30 if $!dialog(twoinvisions) != $!null $chr(123) dialog -x twoinvisions $chr(125) 
    dialog -m twoinvisions twoinvisions
  } 
  else { w.mirc Invision Shutdown 0 }
  if (%iDebug) echo -s 13Finished Two Instance running check
  if ($bits != 32) { error $r.glob(Script,Logo) is designed to work with 32 bit mIRC and will not run correctly with 16 bit versions. | halt }
  if (%iDebug) echo -s 13bits 32 check
  if ($version < 6.1) { error $r.glob(Script,Logo) is designed for mIRC 6.01 and above, please download mIRC 6.01 or above from http://www.mirc.com | halt }
  if (%iDebug) echo -s 13version check
  if $lock(dll) || $lock(run) {
    .timerstartchk $+ $iNetwork off
    var %dum =  $input(The Lock options in mIRC for /run and /dll have been enabled. Invision like most other scripts cannot function correctly under this condition. To fix this $+ $chr(44) go to mIRC Options $crlf $chr(40) $+ ALT + O $+ $chr(41) > General > Lock > and make sure everything in this section is unchecked. Hit OK and then Restart Invision.,516,Invision is locked out!!) 
    set %spacesindir 1 
    halt
  }
  if (%iDebug) echo -s 13Did Lock Check
  if %LogoQuiet != On { .scriptinfo }
  if %LogoQuiet != On { .ibar 1 }
  loadallglobals
  if (%iDebug) echo -s 13Loaded GLobals
  loadallsettings
  if (%iDebug) echo -s 13Loaded Settings
  w.static Script Build 3515  
  var %vd = 1068933333
  if ($r.glob(Invision,LastUpdate) < %vd) { w.glob Invision LastUpdate %vd }
  if ($r.glob(Invision,PatchUpdate) < %vd) { w.glob Invision PatchUpdate %vd }
  if ($r.glob(Invision,LastNews) < %vd) { w.glob Invision LastNews %vd }
  if (%iDebug) echo -s 13Did Last Updates
  if %LogoQuiet != On { .ibar 10 }
  DefaultSettings
  if (%iDebug) echo -s 13Did Default Settings
  unset %OKB*
  ulcleanout
  if (%iDebug) echo -s 13Did Userlist Cleanout
  if %LogoQuiet != On { .ibar 15 }
  set %Screen@ $gettok($dll(invision.dll,invisionRES,_),1,32)
  if (%iDebug) echo -s 13Did Screen Res
  w.glob Script Start $calc( [ $r.glob(Script,Start) ] + 1)
  if (%iDebug) echo -s 13DId Startup Time Clac
  if $r.glob(Script,Start) == 1 { defaultsounds | if (%iDebug) echo -s 13Did Default Sounds }
  if ($r.glob(Invision,SndOpt1) == On) { SoundQ $shortfn($mircdir) $+ $r.glob(Themes,Sound1) }
  if (%iDebug) echo -s 13Did Startup SOund
  if $exists( [ $r.glob(Themes,TrayIcon1) ] ) { .tray -i0 $r.glob(Themes,TrayIcon1) } | else { .tray -ix }
  if %LogoQuiet != On { .ibar 18 }
  if $exists( [ $shortfn($mircdir) $+ patch\i2patch.exe ] ) { .timer -io 1 30 .remove $shortfn($mircdir) $+ patch\i2patch.exe }
  if (%iDebug) echo -s 13Timer set for patch clean
  load-all-inputs
  if (%iDebug) echo -s 13loaded winamp filters
  load-waveout
  if (%iDebug) echo -s 13did winamp waveout
  if %LogoQuiet != On { .ibar 22 }
  unset %Messenger* %Requeue* %Away* %ForceTrig* 
  .rlevel 13
  if (%iDebug) echo -s 13cleared temp dcc
  unset %DirRecCT* %DRN* %DCCW* %BOT* %mp3his* %TWCT* %BI* %LastSound %DST* %DFWK* %DSWK*
  .timer -io 1 0 soundFXtable
  if %LogoQuiet != On { .ibar 30 }
  acrotable
  if (%iDebug) echo -s 13Did Acro Table
  tbar 
  if ($r.glob(Script,Start) == 1) && $r.mirc(Invision,Reboot) != 1 { w.set Colors Colors On | w.set Colors Color.1 12 | w.set Colors Color.2 11 }
  aecho You are running $r.glob(Script,Logo) $r.static(Script,Version) Build $r.static(Script,build) with $r.static(Script,Features) created by $r.static(Script,Author) designed originally for mIRC v6.01 and currently running under mIRC v $+ $version $+ .
  aecho You have now started Invision $r.glob(Script,Start) times since installed.
  if %LogoQuiet != On { .ibar 40 }
  if ($r.glob(Script,Start) == 1) { .timer -o 1 5 firststartimp | w.glob Invision USD $ctime | aecho This is your first time running $r.glob(Script,Logo) $+ , you should go to the Main Settings under ''Invision'' on the Menu bar. If you have questions please use the Invision Help under the Invision Menu. | DefaultSounds } | nobad | if $r.glob(Invision,Halted) == $someid { exit }
  if %LogoQuiet != On { .ibar 50 }
  unset %masstmp
  .flood off
  if %LogoQuiet != On { .ibar 60 }
  if $r.glob(Invision,PDCC) != $null || $r.glob(Invision,PDCC) != off { .pdcc on } | else { .pdcc off } 
  .dcc packetsize $r.glob(Invision,PacketSize) | echo $clradj($ilogo) 4DCC Sends have been optimized for best performance 
  .timerAdjustBW -io 0 10 AdjustBW
  if %LogoQuiet != On { .ibar 70 }
  unset %mp3dirplay %mp3resume 
  if $isfile( [ $r.glob(Themes,ToolBarBG1) ] ) { background -l $r.glob(Themes,ToolBarBG1) } | else { /background -lx }
  if $r.glob(Invision,ScriptGuard) == On { .timer -io 1 0 scriptguard }
  if %LogoQuiet != On { .ibar 80 }
  if $r.glob(Invision,ScriptCheck) == On { .timer -io 1 0 scriptcheck }
  if $r.glob(Invision,PortChk) == On { .timer -io 1 0 portcheck }
  if $r.glob(Invision,SpamList) == $null { w.glob Invision SpamList .pro,inviter,#,www.,http:// }
  if $r.glob(mp3serv,FileTypes) == $null { w.glob mp3serv FileTypes .mp3,.wma,.mpg,.wav }
  if $r.glob(Invision,SizeOn) == $null { w.glob Invision SizeOn On }
  if $r.glob(Invision,RateFixOn) == $null { w.glob Invision RateFixOn On }
  if $r.glob(Invision,SeenTrack) == $null { w.glob Invision SeenTrack Friends }

  if %LogoQuiet != On { .ibar 90 }
  if %LastDCCQueDir == $null { set %LastDCCQueDir C:\ }
  usdstat
  clralltmpdcc
  if %LogoQuiet != On { .ibar 100 }
  if %mp3cachedelay == $null || %mp3cachedelay >= 600 || %mp3cachedelay <= 0 { set %mp3cachedelay 15 }
  .timer -io 1 2 .window -c @Invision 
  .timer -io 1 2 if $!exists( [ $gettok($readini($r.glob(Invision,Theme),n,background,Status),1,44) ] ) == $!true .background -sc $gettok($readini($r.glob(Invision,Theme),n,background,Status),1,44)
  if $r.mirc(Invision,mp3btn) == On { .timer -io 1 5 testmp3 }
  if $exists( [ $gettok($readini($r.glob(Invision,Theme),n,files,TrayIcon1),1,44) ] ) { tray -i0 $readini($r.glob(Invision,Theme),n,files,TrayIcon1) } | else { tray -ix }

  .timer -io 1 1 w.mirc Invision Rebooting 0
  unset %imp*
  if $r.glob(Invision,TS) != $null { .timestamp -fe  $+ $chr(91) $+  $+ $r.glob(Invision,TS) $+  $+ $chr(93) $+  | .timestamp on } | else { .timestamp off } 
  set %startcheck 1
  set %mircdir $mircdir
  w.mirc Wizard Advise $calc($r.mirc(wizard,advise) + 1)
}
; ################################################
; ##                                    EXIT
; ################################################
on *:exit:{
  RequeueSends
  titlebar $tbar.site
  w.mirc Invision Shutdown 1
  .background -sx
  teststop
  if %impscript != i2 && %spacesindir != 1 { SaveAllGlobals }
  unset %spacesindir
}
; ################################################
; ##                            SET DEFAULT SOUNDS
; ################################################
alias DefaultSounds {
  var %ct = 1
  var %sounds = i2start.wav,connect.wav,disconn.wav,kicked.wav,opped.wav,deopped.wav,voiced.wav,devoiced.wav,flood.wav,gainops.wav,banset.wav,banunset.wav,privmsg.wav,invited.wav,addonl.wav,addonu.wav,dccfilex.wav,dccsend.wav,dccfail.wav,dccfail.wav,dccignore.wav,OpenFS.wav,FSsearch.wav,Qfull.wav,FSstart.wav,FSstop.wav,netsplit.wav,pager.wav,topic.wav,chngserv.wav,scanning.wav,chanlock.wav,chanrstr.wav,sitestor.wav,chanjoin.wav,nickspot.wav,mp3start.wav,mp3stop.wav,ipscan.wav,away.wav,back.wav,click.wav,saved.wav,dopen.wav,privmsg.wav,dccchat.wav
  while (%ct <= $numtok(%sounds,44)) {
    w.glob Themes Sound $+ %ct invision\themes\sounds\default\ $+ $gettok(%sounds,%ct,44) 
    inc %ct 1 
  }
}
alias settingsafety {
  if ($r.set(Invision,SeenTrack) == $null) {
    loadallsettings
  }
}
