;==========================================================
; Project    : Complete Protection System (CPS)
; Script      : CPS installation file.
;==========================================================
; Author     : amit (uber @ dalnet #mumbai)
; Email      : amit9815@yahoo.com
; Version    : 7.0
; Filename    : firststep.mrc
; Sections(s) : None
; Copyright (C) 2006 Amit (amit9815@yahoo.com)
;==========================================================

ON *:load: {
  IF ($chr(32) isin $scriptdir) { 
    echo $color(info2) -st *** 4(CPS) Will not install if you have space in folder name. You are currently trying to install it in $scriptdir which has a space in the path try something like c:\mIRC\cps\ or d:\something\blah\cps\ 
    echo $color(info2) -st *** 4(CPS) Setup failed!! 
    .unload -rs $shortfn($script)
  }
  else {
    unset %cpsfirst
    ; Start setup
    echo $color(info2) -st *** Staring 4(CPS) Setup!
    linesep 
    ; Check version
    _check.ver
    ; Set %vars
    echo $color(info2) -st *** 4(CPS) Setting Up Necessary Variables
    linesep 
    set %_cpslogo CPS By Amit
    set %_cps #amit
    set %controlchan #amit
    set %cps.protchan #amit
    set %N.EC OFF
    unset %kicks
    echo $color(info2) -st *** 4(CPS) Switching all warnings (Except Channel Notice) 'ON' by default! You can change them later by 'Warning Option Dialog' 10(Check Menu Bar)
    linesep
    set %_cps.warn.noneng ON
    set %_cps.warn.away ON
    set %_cps.warn.caps ON
    set %_cps.warn.chanads ON
    set %_cps.warn.clone ON
    set %_cps.warn.colors ON
    set %_cps.warn.long ON
    set %_cps.warn.non ON
    set %_cps.warn.punctuation ON
    set %_cps.warn.repeat ON
    set %_cps.warn.slap ON
    set %_cps.warn.sound ON
    set %_cps.warn.swear ON
    set %_cps.warn.text ON
    set %_cps.warn.url ON
    set %_cps.warn.user ON
    set %_mspam ON
    set %_mspam.kstatus OFF
    set %_mspam.istatus ON 
    ; Notify services
    .notify ChanServ
    .notify X
    ; Set more vars
    set %_mspam.mstatus OFF
    set %_cps.echo STATUS
    set %_cps.time ON
    set %spam.words *x*guest*;*www.*;*warez*;*vcd*;*trivia*;*sex*;*script*;*r*u*interested*;*porn*;*pic*;*nude*;*movie*;*leech*;*kid*sex*;*join*#*;*invite*;*http://*;*free*;*f?ck*;*dic*;*cum*;*click*
    ; Set warning messages
    set %_cps.swear.warn Swearing using 'Bad or Unacceptable words' is not allowed in this channel mind your language! [AUTO/WARNING]
    set %_cps.repeat.warn Repeating your self uselessly won't get you anywhere stop repeating here! [AUTO/WARNING]
    set %_cps.text.warn Don't flood this channel by typing lines too fast try to write more words in a line and just slow down a little bit thanks! [AUTO/WARNING]
    set %_cps.long.warn You are breaking channel rules by typing too much words in one line, this is considered as a flood, stop it! [AUTO/WARNING]
    set %_cps.punctuation.warn Don't use too many ?'s and !'s in this channel this is considered a rule breakage! [AUTO/WARNING]
    set %_cps.caps.warn Don't use too many 'UPPER CASE LETTERS' in channel main screen it is considered shouting and a rule breakage! [AUTO/WARNING]
    set %_cps.colors.warn Don't use too many 'CTRL CODES(COLOURS)' in your text it is taken as a flood attempt in channels you can be kicked for it! [AUTO/WARNING]
    set %_cps.urlads.warn Don't advertise those Un Allowed URLS in this channel you can be kicked banned for it! [AUTO/WARNING]
    set %_cps.chanads.warn Don't advertise other channels in this channel it is considered as mass spamming and you might be kicked banned for it! [AUTO/WARNING]
    set %_cps.non.warn This is an English only channel you are speaking in 'Non Letters' which is considered rule breakage; refer that to that in future to avoid a kick ban! [AUTO/WARNING]
    set %_cps.sounds.warn This is a warning don't play mp3's in channel main screen it is strictly against channel rules! [AUTO/WARNING]
    set %_cps.slaps.warn Slapping people or using other such pops on channel mains is not allowed here - Stop now or risk being kicked banned! [AUTO/WARNING]
    set %_cps.user.warn Leave the newbie's alone - don't exploit them with lame exploits, you will be kicked banned for it! [AUTO/WARNING]
    set %_cps.cnote.warn Don't send channel notices this right is a privilege of channel ops! [AUTO/WARNING]
    set %_cps.away.warn Don't spam the channel by using 'Away Scripts' here that send spam notices or advertises that you are away! [AUTO/WARNING]
    set %_cps.clone.warn You have a possible 'CLONE or a GHOST' in the channel! Either kill the ghost or remove your clone ELSE you will be kicked! [AUTO/WARNING]
    set %_cps.noneng.warn This is an English only channel don't speak 'ARABIC or use ASCII' characters here! [AUTO/WARNING]
    linesep 
    ; Check if F9 and shift F9 is free
    _alias.check
    linesep
    ; Load files
    echo $color(info2) -st *** 4(CPS) Now Starting to load scripts!
    var %load = 0
    IF ($_file.check(cps1.mrc) == $true) {
      .load -rs1 $scriptdircps1.mrc
      echo $color(info2) -st *** 4(CPS) loaded Dialog script(Cps1.mrc)!
      inc %load 1
    }
    IF ($_file.check(cps.mrc) == $true) {
      .load -rs1 $scriptdircps.mrc
      echo $color(info2) -st *** 4(CPS) loaded Dialog script(Cps.mrc)!
      inc %load 1
    }
    IF ($_file.check(cpsalias.mrc) == $true) {
      .load -rs1 $scriptdircpsalias.mrc
      echo $color(info2) -st *** 4(CPS) loaded Alias script(Cpsalias.mrc)!
      inc %load 1
    }
    IF ($_file.check(cpsr2.mrc) == $true) {
      .load -rs1 $scriptdircpsr2.mrc
      echo $color(info2) -st *** 4(CPS) loaded Remote script(Cpsr2.mrc)!
      inc %load 1
    }
    IF ($_file.check(cpsr1.mrc) == $true) {
      .load -rs1 $scriptdircpsr1.mrc
      echo $color(info2) -st *** 4(CPS) loaded Remote script(Cpsr1.mrc)!
      inc %load 1
    }
    IF ($_file.check(cpsr.mrc) == $true) {
      .load -rs1 $scriptdircpsr.mrc
      echo $color(info2) -st *** 4(CPS) loaded Remote script(cpsr.mrc)!
      inc %load 1
    }
    linesep
    IF (%load == 6) { echo $color(info2) -st *** 4(CPS) All %load files loaded Correctly! }
    ELSE {
      echo $color(info2) -st *** 4(CPS) Files are missing Re-Download The Script!
      _unload ALL
    }
    linesep
    echo $color(info2) -st *** 4(CPS) Starting to load Hash Tables!
    _loadit
    .FLOOD +c ON
    echo $color(info2) -st *** 4(CPS) mIRC's Internal Flood Protection is now ON!
    echo $color(info2) -st *** 4(CPS) All the Hash Tables loaded Correctly!
    echo $color(info2) -st *** 4(CPS) Setup is done check 'Menu Bar' or Right click in Channel or Status Window!
    ;:NAME
    ;var %name = $input(Enter a name you want to use to login into the BOT!!,e)
    ;IF (%name == $null) {
    ;  echo $color(info2) -a *** 4(CPS) You cannot leave this field blank!!.
    ;  GOTO NAME
    ;}
    ;:PASS
    ;var %pass = $input(Enter the password for your login nick,p)
    ;IF (%pass == $null) {
    ;  echo $color(info2) -a *** 4(CPS) You cannot leave this field blank!!.
    ;  GOTO PASS
    ;}
    ;cps.rvs default lognc %name
    ;cps.rvs default logps %pass
    ;echo $color(info2) -st *** 4(CPS) To login into your bot running CPS type -> /.msg BOT-NICK ~Login %name %pass 
    echo $color(info2) -st *** 4(CPS) mIRC needs to restart click on OK.
    var %a = $$input(CPS needs to restart you mIRC click on OK else setup will Fail!!,o,CPS Needs an mIRC Restart.)
    writeini $shortfn($findfile($scriptdir,mirc.ini,1)) rfiles n2 $shortfn($scriptdirmanifest.mrc)
    set %setup.run YES
    .timer00 1 1 exit
    inc %cpsfirst 1
    HALT
  }
}


alias _check.ver { $iif($version < 6.03,_halt,RETURN) }
alias _halt {
  echo $color(info2) -st *** 4(CPS) You have $version version of mIRC, which is not supported by 4(CPS) get mIRC 6.03 or higher at 12http://www.mirc.com/
  linesep
  echo $color(info2) -st *** 4(CPS) Now unloading!
  IF ($script(cps.mrc)) { .unload -rs $ifmatch }
  IF ($script(cps1.mrc)) { .unload -rs $ifmatch }
  IF ($script(cpsr.mrc)) { .unload -rs $ifmatch }
  IF ($script(cpsr1.mrc)) { .unload -rs $ifmatch }
  IF ($script(cpsr2.mrc)) { .unload -rs $ifmatch }
  IF ($script(cpsalias.mrc)) { .unload -rs $ifmatch }
  .unload -rs $script
  HALT
}

alias _file.check { $iif($isfile($scriptdir $+ $1) == $true,RETURN $ifmatch,sorry $1) }
alias sorry { .echo $color(info) -st *** 7(CPS) Error!!  $+ $1 $+ was not found in $scriptdir $+  ! }
alias _unload {
  IF ($1 == all) {
    .unload -rs $scriptdircps.mrc
    .unload -rs $scriptdircps1.mrc
    .unload -rs $scriptdircpsr.mrc
    .unload -rs $scriptdircpsr1.mrc
    .unload -rs $scriptdircpsr2.mrc
    .unload -rs $scriptdircpsalias.mrc
    unset %_cps*
    unset %_cpslogo
    unset %controlchan
    unset %cps.protchan
    unset %spam.words
    unset %_mspam*
  }
}

alias _alias.check {
  IF (($isalias(F9) == $true) && ($nopath($isalias(F9).fname) != cpsalias.mrc)) {
    echo $color(info2) -st *** 4(CPS) Error!! You already have F9 as an alias in $nopath($isalias(F9).fname) which results in Malfunction of 4(CPS) either remove the alias from the file or install 4(CPS) in a fresh mirc.
    linesep 
    echo $color(info2) -st *** 4(CPS) Error!! Now unloading 4(CPS)
    unset %_cps*
    unset %_cpslogo
    unset %controlchan
    unset %cps.protchan
    IF ($script(cps.mrc)) { .unload -rs $ifmatch }
    IF ($script(cps1.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsr.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsr1.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsr2.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsalias.mrc)) { .unload -rs $ifmatch }
    linesep
    halt
    .timer 1 3 unload -rs $script
  }
  ELSE { echo $color(info2) -st *** 4(CPS) (F9) Alias Compatibility Passed! }
  IF (($isalias(SF9) == $true) && ($nopath($isalias(SF9).fname) != cpsalias.mrc)) {
    echo $color(info2) -st *** 4(CPS) Error!! You already have SHIFT + F9 as an alias in $nopath($isalias(sF9).fname) which results in malfunction of 4(CPS) either remove the alias from the file or install  4(CPS) in a fresh mirc.
    linesep
    echo $color(info2) -st *** 4(CPS) Error!! Now unloading 4(CPS)
    unset %_cps*
    unset %_cpslogo
    unset %controlchan
    unset %cps.protchan
    IF ($script(cps.mrc)) { .unload -rs $ifmatch }
    IF ($script(cps1.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsr.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsr1.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsr2.mrc)) { .unload -rs $ifmatch }
    IF ($script(cpsalias.mrc)) { .unload -rs $ifmatch }
    linesep
    .timer 1 3 .unload -rs $script
    halt
  }
  ELSE { echo $color(info2) -st *** 4(CPS) (SHIFT + F9) Alias Compatibility Passed! }
}

alias _loadit {
  _loadhash
  _loading
}

alias _loadhash {
  unset %_cps.hsh
  var %a = $findfile($scriptdir,*.hsh,0)
  while (%a > 0) {
    set %_cps.hsh $addtok(%_cps.hsh,$upper($remove($nopath($findfile($scriptdir,*.hsh,%a)),.hsh)),44)
    dec %a 1
  }
}

alias _loading {
  var %a = $numtok(%_cps.hsh,44)
  while (%a > 0) {
    IF ($hget($gettok(%_cps.hsh,%a,44)) == $null) { cps.load $upper($gettok(%_cps.hsh,%a,44)) 20 }
    dec %a 1
  }
}
;===========
;end of file
;===========
