All pastes #742214 Raw Edit

Stuff

public text v1 · immutable
·published 2007-10-19 10:25 UTC
rendered paste body
;; // pug.mrc
;; // written by bxi
;; // credits to bxi for the RCON side. (scorebot)
;; // credits to bxi for the main idea


alias rconoff { 
  rcon logaddress_del %rcon.myip 7131 
  rcon logaddress_del %rcon.myip 7131 
  rcon logaddress_del %rcon.myip 7131 
  rcon log off 
}

alias rconon { 
  set %rcon.myip $ip 
  rcon.password %rcon.password 
  rcon.challenge %rcon.ip %rcon.port 
  .timer 1 5 /rcon.logs
}

alias ip return $left($1-,-6)
alias port return $right($1-,5)

on *:udpread:rcon.cmd:{
  if ($window(@rcon)) {
    if ($sockerr > 0) {
      return
    }
    :nextread
    sockread -f %rcon.cmd
    if ($sockbr == 0) return
    if (%rcon.cmd == $null) goto nextread

    else {
      if ($gettok(%rcon.cmd,1,32) == ÿÿÿÿchallenge) set %rcon.challengenumber $gettok(%rcon.cmd,3,32)
      if ($left(%rcon.cmd,5) == ÿÿÿÿl) %rcon.cmd = $remove(%rcon.cmd,$left(%rcon.cmd,5))
      if (%rcon.cmd == $null) return
    }
  }  
  if (%rcon.cmd == $null) goto nextread
  aline -p @rcon %rcon.cmd
  goto nextread
}

on *:udpread:rcon:{
  if ($sockerr > 0) {
    return
  }
  :nextread
  sockread -f %rcon.data
  tokenize 32 %rcon.data
  if ($sockbr == 0) {
    return
  }
  if (%rcon.data == $null) {
    goto nextread
  }
  else {
    if (*"*from*"*"* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*server cvar* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*"* iswm %rcon.data) {
      %rcon.data = $replace(%rcon.data,",$null)
    }
    if (*started map* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*loading* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*[META]* iswm %rcon.data) {
      %rcon.data = $null
    }
    if ($gettok(%rcon.data,7,32) = disconnected) {
      %rcon.data = $gettok(%rcon.data,6,32)
      %rcon.data = $gettok(%rcon.data,1,$asc(<))
      %rcon.data = $remove(%rcon.data,<CT>,<TERRORIST>,<SPECTATOR>)
      echo -a %rcon.data
    }
    if (*shutdown* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*changed name to* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
      %rcon.data = $remove($gettok(%rcon.data,3-,62),changed name to,<CT>,<TERRORIST>,<SPECTATOR>)
      set %rcon.admin $mid(%rcon.data,3)
      rcon say Admin now known as %rcon.data
      goto nextread
    }
    if (*changed name* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*joined team* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*Team TERRORIST triggered VIP_Not_Escaped* iswm %rcon.data) {
      %rcon.data = $replace(%rcon.data,Team TERRORIST triggered VIP_Not_Escaped,10*** Terrorists Win! ***)
    }
    if (*Hostages_Not_Rescued* iswm %rcon.data) {
      %rcon.data = $replace(%rcon.data,Team TERRORIST triggered Hostages_Not_Rescued,10*** Terrorists Win! ***)
    }
    if (*Team TERRORIST triggered Hostages_Not_Rescued* iswm %rcon.data) {
      %rcon.data = $replace(%rcon.data,Team TERRORIST triggered Hostages_Not_Rescued,10*** Terrorists Win! ***)
    }
    if (*killed* iswm %rcon.data) {
      %rcon.data = $null
    }
    if (*attacked* iswm %rcon.data) {
      %rcon.data = $null
    }
    if ($gettok(%rcon.data,1,32) == ÿÿÿÿchallenge) {
      set %rcon.challengenumber $gettok(%rcon.data,3,32)
    }
    if ($left(%rcon.data,5) == ÿÿÿÿl) {
      %rcon.data = $remove(%rcon.data,$left(%rcon.data,5))
      if ((*sv_* !iswm %rcon.data) || (*mp_* !iswm %rcon.data)) {
        %rcon.data = $gettok(%rcon.data,6- $+ $numtok(%rcon.data,32),32)
        if (*"* iswm %rcon.data) {
          %rcon.data = $remove(%rcon.data,")
        }
        if (*<* iswm %rcon.data) {
          %rcon.data = $remove(%rcon.data,$gettok(%rcon.data,3,60))
          %rcon.data = $remove(%rcon.data,$gettok(%rcon.data,2,60))
          %rcon.data = $replace(%rcon.data,<<,)
        }
        if (World triggered Restart_Round_* iswm %rcon.data) {
          %rcon.data = $replace(%rcon.data,World triggered Restart_Round_,$null)
          %rcon.data = $replace(%rcon.data,second,$null)
          %rcon.data = $replace(%rcon.data,(*),$null)
          %rcon.data = $null
        }
        if (*<TERRORIST>* iswm %rcon.data) {
          %rcon.data = $replace(%rcon.data,<TERRORIST>,$null)
        }
        if (*> with * iswm %rcon.data) {
          %rcon.data = $replace(%rcon.data,> with,> with)
        }
        if (*> killed* iswm %rcon.data) {
          %rcon.data = $remove(%rcon.data,$gettok(%rcon.data,-2,60))
          %rcon.data = $remove(%rcon.data,$gettok(%rcon.data,-2,60))
          %rcon.data = $remove(%rcon.data,<<)
          %rcon.data = $replace(%rcon.data,killed,killed)
          if (*<CT* iswm $gettok(%rcon.data,-2,62)) {
            %rcon.death = $gettok(%rcon.data,-2,62)
            %rcon.death2 = $gettok(%rcon.death,2-,32)
            %rcon.data = $replace(%rcon.data,$gettok(%rcon.data,-2,62),$chr(32) $+ killed $+ $chr(32) $+ %rcon.death2)
            echo -a %rcon.data
            %rcon.data = $null
          }
          if (*<T* iswm $gettok(%rcon.data,-2,62)) {
            %rcon.death = $gettok(%rcon.data,-2,62)
            %rcon.death2 = $gettok(%rcon.death,2-,32)
            %rcon.data = $replace(%rcon.data,$gettok(%rcon.data,-2,62),$chr(32) $+ killed $+ $chr(32) $+ %rcon.death2)
            %rcon.data = $null
          }
          if (*<CT* iswm $gettok(%rcon.data,1,62)) {
            %rcon.data = $replace(%rcon.data,$gettok(%rcon.data,1,60),$gettok(%rcon.data,1,60))
            %rcon.data = $null
          }
          if (*<T* iswm $gettok(%rcon.data,1,62)) {
            %rcon.data = $replace(%rcon.data,$gettok(%rcon.data,1,60),$gettok(%rcon.data,1,60))
            %rcon.data = $null
          }
        }
        if (*connected, address* iswm %rcon.data) {
          %rcon.data = $remove(%rcon.data,connected $+ $chr(44) address $gettok(%rcon.data,-1,32),<STEAM_ID_PENDING>)
          %rcon.data = $left(%rcon.data,$calc($len(%rcon.data) - 2))
          if (%full = 1) msg %channel 14»7 %rcon.data connected
        }
        if (*<> disconnected iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*<T> disconnected iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*<CT> disconnected iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*STEAM USERID validated iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*entered the game iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*Spawned_With_The_Bomb* iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*triggered Dropped_The_Bomb iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*triggered Got_The_Bomb iswm %rcon.data) {
          %rcon.data = $null
        }
        if (*triggered Planted_The_Bomb iswm %rcon.data) {
          %rcon.data = $null
        }
        if (Team TERRORIST triggered Target_Bombed* iswm %rcon.data) {
          sortscores
          Twin
        }
        if (Team CT triggered Bomb_Defused* iswm %rcon.data) {
          sortscores
          CTwin
        }
        if (Team TERRORIST triggered Terrorists_Win* iswm %rcon.data) {
          sortscores
          Twin
        }
        if (Team CT triggered CTs_Win* iswm %rcon.data) {
          sortscores
          CTwin
        }
        if (Team CT triggered Target_Saved* iswm %rcon.data) {
          sortscores
          CTwin
        }    
        if (*!login* iswm %rcon.data) && (%admin.pw isin %rcon.data) {
          if (%admin.on == 0) {
            if ($count(%rcon.data,say) != 1) { halt }
            %rcon.admin = $gettok(%rcon.data,1,62)
            set %rcon.admin $remove(%rcon.data, say !login %admin.pw ) 
            set %rcon.admin $remove(%rcon.admin, say_team ) 
            set %rcon.admin $remove(%rcon.admin, say )
            set %rcon.admin $remove(%rcon.admin, _team )
            set %rcon.admin $remove(%rcon.admin, !login ) 
            set %rcon.admin $remove(%rcon.admin, %admin.pw ) 
            set %rcon.admin $remove(%rcon.admin, <T> ) 
            set %rcon.admin $remove(%rcon.admin, <CT> ) 
            set %rcon.admin $remove(%rcon.admin, <SPECTATOR> ) 
            set %rcon.admin $remove(%rcon.admin, (dead) ) 
            /rcon say Your login has been accepted
            .timersay 1 2 rcon say The admin for the pug is %rcon.admin GLHF.  
            msg %channel 1,0The admin for the pug is7:1 %rcon.admin $+ .
            set %admin.on 1
            goto nextread
          }
          else { 
            /rcon say Admin already established.
          }
        }
        if (*!bl* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          return
        }
        if (*!logout* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if (%admin.on == 1) {
            if ($count(%rcon.data,say) != 1) { halt }
            unset %rcon.admin 
            /rcon say You are logged out.  
            set %admin.on 0
            set %rcon.admin $replace(%rcon.admin, say !logout,$null) 
            set %rcon.admin $replace(%rcon.admin, <T>,$null) 
            set %rcon.admin $replace(%rcon.admin, <CT>,$null) 
            goto nextread
          }
          else { 
            /rcon say Admin already established.
          }
        }
        if (*!endpug* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          endpug
          msg %channel %rcon.admin has ended the pug!
          goto nextread
        }
        if (*!restart* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          set %scorebot 0
          /rcon sv_restartround 1 
          goto nextread
        }
        if (*!ff on* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Friendly fire on.
          /rcon mp_friendlyfire 1 
          goto nextread
        }
        if (*!ff off* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Friendly fire off.
          /rcon mp_friendlyfire 0
          goto nextread
        }
        if (*!password* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          set %pw $read(pw.txt)
          /rcon sv_password %pw
          msg %channel 5Password changed
          /rcon say Server password is now %pw
          goto nextread
        }
        if (*!teams* iswm %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say CTs: %team.CT.rcon
          /rcon say Ts: %team.T.rcon
          goto nextread
        }
        if (*!score* iswm %rcon.data) {
          if (%half.1 = 1) {
            /rcon say Game scores - CT: %CTscore T: %Tscore
            goto nextread
          }
          if (%half.2 = 1) {
            /rcon say Game scores - CT: $calc(%CTscore + %Tsh1) T: $calc(%Tscore + %CTsh1)
            goto nextread
          }
        }
        if (*!map de_dust2 iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_dust2
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_dust2
          .timer 1 2 /rcon changelevel de_dust2
          goto nextread
        }
        if (*!map de_cpl_strike iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_cpl_strike
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_cpl_strike
          .timer 1 2 /rcon changelevel de_cpl_strike
          goto nextread
        }
        if (*!map de_cpl_fire iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_cpl_fire
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_cpl_fire
          .timer 1 2 /rcon changelevel de_cpl_fire
          goto nextread
        }
        if (*!map de_cpl_mill iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_cpl_mill
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_cpl_mill
          .timer 1 2 /rcon changelevel de_cpl_mill
          goto nextread
        }
        if (*!map de_aztec iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_aztec
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_aztec
          .timer 1 2 /rcon changelevel de_aztec
          goto nextread
        }
        if (*!map de_nuke iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_nuke
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_nuke
          .timer 1 2 /rcon changelevel de_nuke
          goto nextread
        }
        if (*!map de_inferno iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_inferno
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_inferno
          .timer 1 2 /rcon changelevel de_inferno
          goto nextread
        }
        if (*!map de_train iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_train
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_train
          .timer 1 2 /rcon changelevel de_train
          goto nextread
        }
        if (*!map de_cbble* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          /rcon say Changing map to de_cbble
          /rcon mp_friendlyfire 0
          set %rcon.scorebot 0
          msg %channel 3Map has been changed to de_cbble
          .timer 1 2 /rcon changelevel de_cbble
          goto nextread
        }
        if (*!get* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          if ( !%flooding ) {
            amsg 3» Player Needed @ 3#ESPug 3:14 connect %rcon.ip.port $+ ; password %pw 3«
            rcon say Attempting to get a Player!
            set -u5 %flooding on
          }
          goto nextread
        }
        if (*!irc* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          if (*.com* !isin %rcon.data) && (*.net* !isin %rcon.data) && (*.org* !isin %rcon.data) && (*http://* !isin %rcon.data) {
            set %ircmsg %rcon.data
            set %ircmsg $replace(%ircmsg, (dead),$null) 
            set %ircmsg $replace(%ircmsg,say ,$null)
            set %ircmsg $replace(%ircmsg, !irc ,$null)
            set %ircmsg $replace(%ircmsg,<CT>,$null)
            set %ircmsg $replace(%ircmsg,say_team !irc,$null)
            set %ircmsg $replace(%ircmsg,<T>,$null)
            set %ircmsg $replace(%ircmsg,%rcon.admin,$null)
            msg %channel 14Message ingame from %rcon.admin $+ 14:7 %ircmsg
            goto nextread
          }
        }
        if (*!kick* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          if (*.com* !isin %rcon.data) && (*.net* !isin %rcon.data) && (*.org* !isin %rcon.data) && (*http://* !isin %rcon.data) {
            set %rcon.data $replace(%rcon.data,<T>,$null)
            set %rcon.data $replace(%rcon.data,<CT> ,$null)
            set %rcon.data $replace(%rcon.data,<>,$null)
            set %rcon.data $replace(%rcon.data, (dead),$null)
            set %rcon.kick %rcon.data
            set %rcon.kick $replace(%rcon.kick,say ,$null)
            set %rcon.kick $replace(%rcon.kick,!kick ,$null)
            set %rcon.kick $replace(%rcon.kick, %rcon.admin ,$null)
            /rcon say Attempting to kick player: %rcon.kick
            /rcon kick %rcon.kick
            goto nextread
          }
        }
        if (*!stophalf* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if ($count(%rcon.data,say) != 1) { halt }
          if (%half.1 = 1) {
            /rcon say 1st half stopped. !lo3 to restart.
            set %scorebot 0
            msg %channel 12First half has been stopped!
          }
          if (%half.2 = 1) {
            /rcon say 2nd half stopped. !lo3 to restart.
            set %scorebot 0
            msg %channel 12Second half has been stopped!
          }
        }
        if (*!lo3* iswm %rcon.data) && (%rcon.admin isin %rcon.data) {
          if (%half.1 = 1) {
            msg %channel 3The 1st half is about to begin!
            rcon say Configuring war settings...
            lo3
            .timersay 1 1 /rcon say To cancel the half type !stophalf
            msg %channel 7War settings are being set...
            .timerlo3 1 3 msg %channel 7The match has gone LIVE! (1st half)
          }
          if (%half.2 = 1) {
            msg %channel 3The 2nd half is about to begin!
            lo3
            /rcon say Second half commencing. 
            /rcon say To cancel the half type !stophalf
            .timerlo3 1 3 msg %channel 7The match has gone LIVE! (2nd half)
          } 
        }
        else {
          %rcon.data = $null
        }
      }
      if (*<T>* iswm %rcon.data) {
        %rcon.data = $replace(%rcon.data,<T>,$null)
      }
      if (*<CT>* iswm %rcon.data) {
        %rcon.data = $replace(%rcon.data,<CT>,$null)
      }
      if (* $chr(40) $+ CT* iswm %rcon.data) {
        %rcon.data = $replace(%rcon.data,$chr(40) $+ CT,2 $+ $chr(40) $+ CT)
      }
      if (* $chr(40) $+ T* iswm %rcon.data) {
        %rcon.data = $replace(%rcon.data,$chr(40) $+ T,10 $+ $chr(40) $+ T)
      }
      if (Team CT triggered Target_Saved* iswm %rcon.data) {
        sortscores
        CTwin
      }        
    }
    if (%rcon.data == $null) goto nextread
  }
  if (%rcon.scorebot == 1) {
    if (%rcon.data != $null) && (*.com* !isin %rcon.data) && (*.net* !isin %rcon.data) && (*.org* !isin %rcon.data) && (*http://* !isin %rcon.data) {
      msg %rcon.scorebotchan %rcon.data
    }
  }
  if (%rcon.data != $null) {
    aline -p @rcon %rcon.data
  }
  goto nextread
}

on *:sockwrite:rcon:{ if ($sockerr) aline @rcon $sock().wserr }

on *:TEXT:!commands:#espug:{ 
  .notice $nick Commands3:14 coming soon
}
on *:CONNECT:{ 
  mode $me +x
  starthltv
  .timer1 1 3 joinchannel
}

alias joinchannel join %channel

alias settopic {
  set %playernum $calc($numtok(%warmestring,59) + 1) $+ / $+ $calc(2 * %mode) 
  set %channel.colour 3» 14#3es14pug 3p14ower3ed 14by #epicservers and #Plutonic 3«
  set %site.colour 3Commands:14 14!Pug (Map) !join !leave !players !kill
  set %sepleft 3» 
  set %sepright 3«
  set %ipcol 14Server IP:14 %rcon.ip.port 3» 14Please wait for the bot to msg you details. 3«
  set %status %col.2 3Status:
  set %admin %col.2 3Admin:
  set %topic.start %channel.colour %ipcol %status 
}

alias topicstart { 
  settopic 
  .topic %channel %topic.start 14pug started on3 $iif(%map,%map,de_dust2) $+ 14 type !join to play. 3«
}

alias topicend { 
  settopic 
  .topic %channel %topic.start 14type !pug <map> to start a pug 3« 
}
alias topicingame {
  settopic 
  .topic %channel %topic.start 14Ingame on %map 3« 
}
alias topicdis { 
  settopic 
  .topic %channel %topic.start 14Disabled 3« 
}

alias playernotice { 
  var %x = $numtok(%warmestring, 59) 
  while (%x) { 
    notice $gettok(%warmestring,%x,59) Details10: connect %rcon.ip.port  $+ ; password %pw 
    dec %x
  } 
}

alias passnotice {
  notice %nick k4#espug - 14Details3:14 connect %rcon.ip.port  $+ ; password %pw  
}

alias adminnotice {
  var %x = $numtok(%pugstring, 59) 
  while (%x) { 
    var %adminnick = $gettok(%pugstring, %x, 59) 
    notice %adminnick 3#espug - 14Details3:14 connect %rcon.ip.port  $+ ; password %pw - Admin Password3: %admin.pw (!login %admin.pw $+ )
    dec %x
  } 
}

alias sorttok { 
  var %x = $numtok(%warmestring,59) 
  var %kot 
  while (%x) { 
    var %r = $rand(1,%x) 
    %kot = %kot $+ $gettok(%warmestring,%r,59) $+ ; 
    set %warmestring $remtok(%warmestring,$gettok(%warmestring,%r,59),1,59) 
    dec %x 
  } 
  set %warmestring %kot
}

on *:close:@rcon:{
  if (%rcon.scorebot == 1) {
    set %rcon.scorebot 0
  }
  set %rcon.myip $ip
  sockclose rcon.cmd
  sockudp -n rcon.cmd %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " log off
  sockudp -n rcon 7131 %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " logaddress_del %rcon.myip 7131
  sockclose rcon
  sockclose rcon.cmd
}

alias endpug { 
  mode %channel -v %pugstring 
  var %x = $numtok(%warmestring, 59) 
  while (%x) {
    var %nick = $gettok(%warmestring, %x, 59) 
    var %r = $addtok(%r, %nick, 32) 
    if ($numtok(%r,32) = $modespl) { 
      mode %channel $+(-, $str(v, $modespl)) %r 
      unset %r 
    } 
    dec %x
  } 
  if (%r) { 
    mode %channel $+(-, $str(v, $numtok(%r,32))) %r 
  } 
  set %pw $read(pw.txt)
  rcon say The Pug has been Ended! Idle #espug, #epicservers, #Plutonic
  rcon sv_password %pw
  rcon mp_friendlyfire 0
  set %scorebot 0
  set %pugging 0 
  unset %full %warmestring %pugstring %admin.pw %team.CT %team.T %half.2 %half.1 %score* %T* %CT*
  .timer11 off
  .timer12 off
  .timer13 off
  set %teams.on 0
  set %admin.on 0
  topicend
  .timer 1 4 rcon map de_dust2
}

alias Twin {
  if (%scorebot = 1) {
    aline -p @rcon Terrorists Win
    if (%half.1 = 1) {
      msg %channel 14,0» 7Terrorist Win! 14CT:7 %CTSCORE - 14T:7 %TSCORE
      rcon say Terrorist Win! T: %Tscore CT: %CTscore
    }
    if (%half.2 = 1) {
      msg %channel 14,0» 7Terrorist Win! 14CT:7 $calc(%CTscore + %Tsh1) - 14T:7 $calc(%Tscore + %CTsh1)
      rcon say Terrorist Win! T: $calc(%Tscore + %CTsh1) CT: $calc(%CTscore + %Tsh1)
    }
  }
}

alias CTwin {
  if (%scorebot = 1) {
    aline -p @rcon Counter-Terrorists Win
    if (%half.1 = 1) {
      msg %channel 14,0» 7Counter-Terrorist Win! 14CT:7 %CTSCORE - 14T:7 %TSCORE
      rcon say Counter-Terrorist Win! T: %Tscore CT: %CTscore
    }
    if (%half.2 = 1) {
      msg %channel 14,0» 7Counter-Terrorist Win! 14CT:7 $calc(%CTscore + %Tsh1) - 14T:7 $calc(%Tscore + %CTsh1)
      rcon say Counter-Terrorist Win! T: $calc(%Tscore + %CTsh1) CT: $calc(%CTscore + %Tsh1)
    }
  }
}

on *:TEXT:!score:%channel:{
  if (%half.1 = 1) {
    msg # 3Game scores (First Half) - 14CT:7 %CTscore 14T:7 %Tscore
  }
  if (%half.2 = 1) {
    msg # 3Game scores (Second Half) - 14CT:7 $calc(%CTscore + %Tsh1) 14T:7 $calc(%Tscore + %CTsh1)
  }
}

alias sortscores {
  %scores = $gettok(%rcon.data,5-,32)
  set %scores $remove(%scores, $chr(40) )
  set %scores $remove(%scores, $chr(41) )
  set %scores $remove(%scores, CT )
  set %scores $remove(%scores, T )
  set %scores $remove(%scores, 10 )
  set %scores $remove(%scores, 2  )
  set %CTscore $left(%scores,3)
  set %CTscore $remove(%CTscore,$chr(32))
  set %Tscore $right(%scores,3)
  set %Tscore $remove(%Tscore,$chr(32))
  if (%scorebot = 1) {
    if ($calc(%CTscore + %Tscore) = 15) && (%half.1 = 1) {
      if (%CTscore > %Tscore) msg %channel 14Half Time: 10Counter-Terrorist currently beating the 3Terrorist14 %TSCORE to %CTSCORE 
      if (%Tscore > %CTscore) msg %channel 14Half Time: 3Terrorist currently beating the 10Counter-Terrorist14 %CTSCORE to %TSCORE 
      set %CTsh1 %CTscore
      set %Tsh1 %Tscore
      set %half.2 1
      unset %half.1
      unset %scorebot 
      /rcon say First Half Over. CTs: %CTscore Ts: %Tscore 
      /rcon say Round restarting in 5 seconds. Please change teams.
      /rcon say To commence second half type !lo3
      /rcon sv_restartround 5
      unset %CTscore
      unset %Tscore
      halt
    }
    if (%half.2 = 1) {
      if ($calc(%CTscore + %Tsh1) = 16) || ($calc(%Tscore + %CTsh1) = 16) {
        set %CTsh2 %CTscore
        set %Tsh2 %Tscore
        unset %scorebot 
        set %CTtotal $calc(%CTsh2 + %Tsh1)
        set %Ttotal $calc(%Tsh2 + %CTsh1)
        if (%CTtotal > %Ttotal) {
          /rcon say Match Completed. *** Counter Terrorists Win! ***
          msg %channel 14Match Completed: 10Counter-Terrorist 14beat the 10Terrorist14 %CTtotal to %Ttotal
          /endpug   
          halt
        }
        if (%CTtotal < %Ttotal) {
          /rcon say Match Completed. *** Terrorists Win! ***
          msg %channel 14Match Completed: 10Terrorist 14beat the 10Counter-Terrorist14 %Ttotal to %CTtotal   
          /endpug       
          halt
        }      
      }
      if ($calc(%CTscore + %Tscore) = 15) {
        set %CTsh2 %CTscore
        set %Tsh2 %Tscore
        unset %scorebot 
        set %CTtotal $calc(%CTsh2 + %Tsh1)
        set %Ttotal $calc(%Tsh2 + %CTsh1)
        /rcon say Match Completed. *** It was a tie! *** CTs: %CTtotal Ts: %Ttotal
        msg %channel 14Match Completed: 14It was a tie!14 %CTtotal - %Ttotal 
        /endpug     
      }
      elseif ($calc(%CTscore + %Tscore) >= 90) {
        /rcon sv_restartround 1
      }
    }
  }
}

alias endfordisable {
  mode %channel -v %pugstring
  var %x = $numtok(%warmestring, 59) 
  while (%x) {
    var %nick = $gettok(%warmestring, %x, 59)
    var %r = $addtok(%r, %nick, 32)


    if ($numtok(%r,32) = $modespl) {
      mode %channel $+(-, $str(v, $modespl)) %r

      unset %r
    }

    dec %x 
  } 

  if (%r) { 
    mode %channel $+(-, $str(v, $numtok(%r,32))) %r
  }
  set %pw $read(pw.txt)
  /rcon map de_dust2
  /rcon say Pug ending. 
  /rcon sv_password %pw
  /rcon mp_friendlyfire 0
  set %scorebot 0
  set %pugging 0 
  unset %full 
  unset %warmestring
  unset %pugstring
  unset %admin.pw
  unset %team.CT
  unset %team.T
  unset %half.2 
  unset %half.1
  unset %score*
  unset %T*
  unset %CT*
  .timer11 off
  .timer12 off
  set %teams.on 0
  set %admin.on 0
}


alias rcon.password {
  if ($window(@rcon)) {
    if (!$1) {
      aline @rcon You need to enter an rcon password.
      aline @rcon Right click or type /settings
      halt
    }
    set %rcon.password $1-
    aline @rcon the rcon password has been saved as " $+ $1- $+ "
    else {
      echo -a The RCON window is not open! Select it from the popup menu.
    }
  }
}

alias rcon.challenge {
  if ($window(@rcon)) {
    if (!$1) {
      aline @rcon You need to enter an ip address
      aline @rcon Right click or type /settings
      halt
    }
    if (!$2) {
      set %rcon.ip $1
      set %rcon.port 27015
    }
    else {
      set %rcon.ip $1
      set %rcon.port $2
    }
    sockudp -kn rcon.cmd %rcon.ip %rcon.port ÿÿÿÿchallenge rcon
  }
  else {
    echo -a The RCON window is not open! Select it from the popup menu.
  }
}

alias rcon.logs {
  if ($window(@rcon)) {
    if ((!%rcon.ip) || (!%rcon.port) || (!%rcon.challengenumber) || (!%rcon.password)) {
      aline @rcon Some components missing! Right click or type /settings
    }
    else {
      ; enable server log stuff
      sockudp -kn rcon.cmd %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " mp_logmessages 1
      sockudp -kn rcon.cmd %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " mp_logfile 1
      sockudp -kn rcon.cmd %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " mp_logdetail 0
      ; enable logging
      sockudp -kn rcon.cmd %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " log on
      ; set log address
      set %rcon.myip $ip
      sockudp -k rcon 7131 %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " logaddress_add %rcon.myip 7131
    }
  }
  else {
    echo -a The RCON window is not open! Select it from the popup menu.
  }
}

alias rcon {
  if ($window(@rcon)) {
    if ((!%rcon.ip) || (!%rcon.port) || (!%rcon.challengenumber) || (!%rcon.password)) {
      aline @rcon some vital components are missing, please make sure the ip, port, challenegenumber, and rcon password all exist.
    }
    else {
      sockudp -kn rcon.cmd %rcon.ip %rcon.port ÿÿÿÿrcon %rcon.challengenumber " $+ %rcon.password $+ " $1-
    }
  }
  else {
    echo -a The RCON window is not open! Select it from the popup menu.
  }
}

alias scorebot {
  if ($window(@rcon)) {
    if ((!%rcon.ip) || (!%rcon.port) || (!%rcon.challengenumber) || (!%rcon.password)) {
      aline @rcon Some vital components are missing! Right click or type /settings
    }
    else {
      set %channel $input(What channel do you want the scorebot in?,ey)
      if (%channel == $null) {
        set %rcon.scorebot 0
        echo -a *** You must provide a channel name!
      }
      else {
        if ($left(%channel,1) != $chr(35)) {
          set %rcon.scorebot $chr(35) $+ %rcon.scorebot
        }
        if ($me ison %channel) {
          set %rcon.scorebot 1
        }
        else {
          join %channel
          set %rcon.scorebot 1
        }     
      } 
    }
  }
  else {
    echo -a The RCON window is not open! Select it from the popup menu, then run the scorebot.
  }
}

on *:TEXT:!map *:%channel:{
  if ( %pugging = 1 ) {
    if ( $nick isin %pugstring ) || ( $nick isop %channel ) {
      if ( $2 isin %maps ) {
        rcon changelevel $2 
        set %map $2
        msg %channel 6The map has been changed to: %map
      }
      if ( $2 !isin %maps ) { 
        .notice $nick No such map. 
      }
    }
  }
}

on *:TEXT:!addid *:%channel:{
  if ( $nick isop %channel ) {
    write idbans.txt $nick banned $2 - $iif($3-,$ifmatch,Unset)
    msg $chan $2 has been added to the banlist. - Reason: $iif($3-,$ifmatch,Unset)
    rcon banid 0 $2
  }
}

on *:TEXT:!pug:%channel:{
  if (%disable = 1) { .notice $nick Pug currently disabled | halt }
  if (%pugging = 1) { .notice $nick Pug has already been started | halt }
  if ($nick isin %pugstring) { .notice $nick You are already admin of this pug | halt }
  if ($nick isin %warmestring) { .notice $nick You are already added | halt } {
    unset %pugstring  
    set %pug.address $address($nick,1)  
    set %pug.ban 15
    /inc -z %pug.ban 1
    set %admin.quit 1    
    /inc -c %admin.quit 1
    unset %warmestring
    unset %admin.pw
    unset %team.CT
    unset %team.T
    set %rcon.says 0
    set %teams.on 0 
    unset %rcon.admin
    set %admin.on 0
    set %pugstring $nick
    .timer11 1 5400 endpug
    .timer12 1 5400 msg %channel 11Pug has been ended, 30 minute timeout!
    set %pugging 1
    ;-- End 
    set %pw $read(pw.txt)
    set %admin.pw $read(adminpw.txt) 
    set %half.1 1
    rcon map de_dust2
    set %map de_dust2
    /rcon sv_password %pw
    topicstart
    amsg 3«14]14[3» 14A pug has been started on %map at 3#ESpug 14by $nick - type !join to play! 3«14]14[3»
  } 
  else {
    .notice $nick You are already in the PUG! 
  }
}

on *:TEXT:!pug *:%channel:{
  if (%disable = 1) { .notice $nick Pug currently disabled | halt }
  if (%pugging = 1) { .notice $nick Pug has already been started | halt }
  if ($nick isin %pugstring) { .notice $nick You are already admin of this pug | halt }
  if ($2 isin %maps) {
    /rcon map $2
    set %map $2
  }
  else { 
    msg %channel Invalid map 
    halt
  }
  if ($nick isin %warmestring) { .notice $nick You are already added | halt } {
    unset %pugstring  
    set %pug.address $address($nick,1)  
    set %pug.ban 15
    /inc -z %pug.ban 1
    set %admin.quit 1    
    /inc -c %admin.quit 1
    unset %warmestring
    unset %admin.pw
    unset %team.CT
    unset %team.T
    set %rcon.says 0
    set %teams.on 0 
    unset %rcon.admin
    set %admin.on 0
    set %pugstring $nick
    .timer11 1 5400 endpug
    .timer12 1 5400 msg %channel Pug ended, 30 minute timeout!
    set %pugging 1
    ;-- End 
    set %pw $read(pw.txt)
    set %admin.pw $read(adminpw.txt) 
    set %half.1 1
    /rcon sv_password %pw
    topicstart
    amsg 3»14 A pug has been started on %map 14at 3#espug 14by $nick - type !join to play! 3«
  } 
  else {
    .notice $nick You are already in the PUG! 
  }
}

on *:TEXT:!join:%channel:{ 
  if (%full == 1) { .notice $nick Sorry, pug already in progress | halt } 
  if (%pugging == 0) { .notice $nick No pug in progress | halt } 
  if ($nick !isin %warmestring) && ($nick !isin %pugstring) {
    %warmestring = $addtok(%warmestring, $nick, 59)
    var %user = 1 
    var %users = $gettok(%warmestring,0,59) 
    var %msgstring 
    while (%user <= %users) { 
      %msgstring = %msgstring $chr(44) $gettok(%warmestring,%user,59) 
      inc %user 
    } 
    settopic 
    msg %channel 3» 14Added $nick to the pug! 3( $+ %playernum $+ )
    set %teams.on 0
    ignore -u3 $nick
  }
  else {
    halt
  }
  if ($gettok(%warmestring,0,59) == %modeplayer) {
    mode # +m
    .timer11 off
    .timer12 off
    .timer13 off
    topicingame
    rcon sv_restartround 1
    set %rcon.says 0
    set %teams.on 1 
    set %full 1    
    set %half.1 1
    sorttok
    if (%mode = 5) {
      set %team.CT 10 $gettok(%pugstring,1,59) 2 $gettok(%warmestring,5,59) 10 $gettok(%warmestring,3,59) 2 $gettok(%warmestring,8,59) 10 $gettok(%warmestring,9,59) 
      set %team.T 5 $gettok(%warmestring,1,59) 3 $gettok(%warmestring,2,59) 5 $gettok(%warmestring,4,59) 3 $gettok(%warmestring,6,59) 5 $gettok(%warmestring,7,59) 
      set %team.CT.rcon $gettok(%pugstring,1,59) $gettok(%warmestring,5,59) $gettok(%warmestring,3,59) $gettok(%warmestring,8,59) $gettok(%warmestring,9,59) 
      set %team.T.rcon $gettok(%warmestring,1,59) $gettok(%warmestring,2,59) $gettok(%warmestring,4,59) $gettok(%warmestring,6,59) $gettok(%warmestring,7,59) 
    }
    msg %channel 2CT: %team.CT
    msg %channel 10T: %team.T
    adminnotice
    playernotice
    .timermoderate 1 8 moderation
    starthltv
  }
}

alias moderation { mode %channel -m }
on *:QUIT: {
  if ($nick == %pugstring) && (%teams.on != 1) {
    endpug
  } 
  if ($nick isin %warmestring) {
    if (%full == 1) { halt }
    %warmestring = $remtok(%warmestring,$nick, 59) 
    msg %channel » Removed $nick from the pug! ( $+ %playernum $+ )
    unset %team.CT
    unset %team.T
    set %teams.on 0 
  }
} 


on *:NICK: {
  if ($nick isin %pugstring) { %pugstring = $remtok(%pugstring, $nick, 59) | %pugstring = $addtok(%pugstring, $newnick, 59) }
  if ($nick isin %warmestring) { %warmestring = $remtok(%warmestring, $nick, 59) | %warmestring = $addtok(%warmestring, $newnick, 59) }
}



on *:PART:%channel:{
  if (%full == 1) { halt } 
  if ($nick isin %pugstring) && (%pug.ban >= 1) {
    endpug     
    set %pug.ban.mask $mask(%pug.address,3)
    /ban -u86400 %channel %pug.ban.mask 
    unset %pugstring 

  } 
  if ($nick isin %pugstring) {
    endpug
  }
  if ($nick isin %warmestring) && (%teams.on != 1) {
    %warmestring = $remtok(%warmestring,$nick, 59) 
    msg %channel 3» 14Removed $nick from the pug! 3( $+ %playernum $+ )
    unset %team.CT
    unset %team.T
    set %teams.on 0 
  }
}

on *:KICK:%channel: {
  if ($knick isin %pugstring) endpug 
  if ($knick isin %warmestring) { %warmestring = $remtok(%warmestring,$knick, 59) | msg %channel 3»14 Removed $knick from the pug! 3( $+ %playernum $+ ) } 
}

on *:TEXT:!endpug:%channel: { 
  if (%pugging = 0) { halt }
  if ($nick !isin %pugstring) && ($nick !isop %channel ) { .notice $nick You Are Not An Admin | halt }
  if ($nick isin %pugstring) && (%pug.ban >= 1) {
    if ($nick !isop $chan) {
      set %pug.ban.mask $mask(%pug.address,3)
      /ban -u86400 %channel %pug.ban.mask 
      /kick %channel $nick Starting and ending within 15 seconds. 24 hour ban!
    }
    endpug
    halt
  } 
  if ($nick isin %pugstring) || ($nick isop %channel) {
    /rcon say Pug ended. Idle %channel !
    endpug
  }
}


on *:TEXT:!override *:%channel:{
  if ($nick isop %channel) {
    if ($2 isin %warmestring) {
      msg %channel 3»14 $2 is now admin!
      %warmestring = $addtok(%warmestring,%pugstring,59)
      %warmestring = $remtok(%warmestring,$2,59)
      set %pugstring $2
      topic
    }
    else { .notice $nick $2 is not in pug.
    }
  }
}


on *:TEXT:!teams:%channel: { 
  if (%pugging = 1) {
    if (%teams.on == 0) { notice $nick Pug not started yet | halt }
    msg %channel 2CT: %team.CT
    msg %channel 10T: %team.T
    ignore -u4 $nick
  }
  else { .notice $nick No Pug in progress.
  }
}

on *:TEXT:!details:%channel:{ 
  if (%teams.on == 1) {
    if ($nick isin %warmestring) {
      set %nick $nick
      passnotice
      unset %nick
    }
    if ($nick isin %pugstring) || ($nick isop %channel) {
      adminnotice
    }
  }
}

on 1:CONNECT: {
  set %rcon.ip $ip(%rcon.ip.port)
  set %rcon.port $port(%rcon.ip.port)
  set %rcon.scorebotchan %channel
  set %pugbot.channel %channel
  set %scorebot 0
  .timer 1 5 /join %channel
  rconoff
  rconon  
  settopic
}

on 1:EXIT: {
  rconoff
  /save -rv vars.ini
}

on 1:DISCONNECT: {
  set %scorebot 0
  set %pugging 0 
  endpug
  unset %warmestring
  unset %pugstring
  unset %rcon.admin
  unset %admin.on
  unset %admin.pw
  unset %team.CT
  unset %team.T
  set %teams.on 0 
  rcon off
}

on *:START: {
  .load -rv vars.ini
  .window -ae @rcon
  rconoff
  rconon
  set %maps de_dust2 de_inferno de_nuke de_train de_aztec de_cbble de_cpl_mill de_cpl_fire de_prodigy
  set %mode 5
  set %modeplayer 9
  server irc.gamesurge.net
}

alias startit {
  /window -ae @rcon
  rconoff
  rconon
  set %maps de_dust2 de_inferno de_nuke de_train de_aztec de_cbble de_cpl_mill de_cpl_fire de_prodigy
  set %mode 5
  set %modeplayer 9
}


on *:TEXT:!leave:%channel: { 
  if ($nick !isin %warmestring) { .notice $nick You are not in the list! | halt } {
    %warmestring = $remtok(%warmestring,$nick,1,59) 
    var %user = 1 
    var %users = $gettok(%warmestring,0,59) 
    var %msgstring | while (%user <= %users) { 
      %msgstring = %msgstring $chr(44) $gettok(%warmestring,%user,59) 
      inc %user 
    } 
    settopic 
    msg %channel 3»14 Removed $nick from the pug! 3( $+ %playernum $+ ) 3«
  } 
  else { 
    .notice $nick Sorry, you are not in the pug! 
  } 
}

on *:TEXT:!delip:?: {
  if ($nick isop %channel) {
    /rcon logaddress_del $ip 7131
  }
}

on *:TEXT:!nick *:%channel:{
  if ($nick isop %channel) {
    nick $2
  }
}

on *:TEXT:!players:%channel:{ 
  if ( !%flood ) {
    if (%pugging == 1) { 
      var %user = 1 
      var %users = $gettok(%warmestring,0,59) 
      var %msgstring | while (%user <= %users) { 
        %msgstring = %msgstring $chr(44) $gettok(%warmestring,%user,59) 
        inc %user 
      } 
      settopic 
      msg %channel 3( $+ %playernum $+ ) 14Admin3:14 %pugstring $+ . Players3:14 $remove(%msgstring,$chr(44)) $+ .
      ;-- End 
      unset %admin.txt
      unset %players.txt
      unset %playernum

    } 
    else { msg %channel A pug hasnt been started, type !pug <map> to start a pug. }
  }
  set -u3 %flood on
}


on *:TEXT:!rcon *:?:{ 
  if ($nick isop %channel) {
    rcon $2-
    msg $nick Command successfully entered: $2-
  }    
  else { 
    msg $nick You are not an operator.
  }
}

on *:TEXT:!restart:%channel:{ 
  if ($nick isop %channel) {
    if (%pugging = !) { endpug }
    /quit Restarting...
    /server irc.gamesurge.net
  }    
  else { msg $nick You are not an operator.
  }
}

on *:TEXT:!scorebot on:?:{ 
  if (%scorebot == 1) { .notice $nick Scorebot already enabled. | halt } 
  if ($nick isop %channel) {
    set %scorebot 1
    set %rcon.says 0
    msg %channel 14 Scorebot enabled
  }    
  else { msg $nick You are not an operator.
  }
}

on *:TEXT:!scorebot off:?:{ 
  if (%scorebot != 1) { .notice $nick Scorebot already disabled. | halt } 
  if ($nick isop %channel) {
    unset %scorebot 
    unset %rcon.says
    msg %channel 14 Scorebot disabled
  }    
  else { msg $nick You are not an operator.
  }
}

on *:TEXT:!scorebot on:%channel:{ 
  if (%scorebot == 1) { .notice $nick Scorebot already enabled. | halt } 
  if ($nick isop %channel) {
    set %scorebot 1
    set %rcon.says 0
    msg %channel 14 Scorebot enabled by $nick
  }    
  else { msg $nick You are not an operator.
  }
}

on *:TEXT:!scorebot off:%channel:{ 
  if (%scorebot != 1) { .notice $nick Scorebot already disabled. | halt }  
  if ($nick isop %channel) {
    unset %scorebot 
    unset %rcon.says
    msg %channel 14 Scorebot disabled by $nick
  }    
  else msg $nick You are not an admin.
}

on *:TEXT:!serverpw *:?:{ 
  if ($nick isop %channel) {
    set %pw $2-
    /rcon sv_password $2-
    /rcon say Server password changed to: $2-
    msg $nick Server password set to: $2-
  }    
  else { msg $nick You are not an bot operator.
  }
}

on *:TEXT:!adminpw *:?:{ 
  if ($nick isop %channel) {
    msg $nick Admin password set to: $2-
    set %admin.pw $2-
    unset %rcon.admin
    set %admin.on 0
    /rcon say Admin reset.
  }    
  else { msg $nick No admin allocated.
  }
}

on *:JOIN:%channel:{
  if ( $address($nick,1) == $gettok($gettok($address($nick,1),2,$asc(@)),1,$asc(.))) {
    mode %channel +o $nick 
    notice $nick Welcome $nick $+ , aop reason: Bot maker.
  }
}

on *:TEXT:!chat *:%channel:{ 
  if ($nick isop %channel) {
    /rcon say $nick - $2-
  }    
  else { msg $nick You are not admin.
  }
}


on *:TEXT:!chat *:?:{ 
  if ($nick isop %channel) {
    /rcon say $nick - $2-
  }    
  else { msg $nick You are not admin.
  }
}

on *:TEXT:!ip *:?:{ 
  if ($nick isop %channel) {
    msg $nick IP set to: $2
    set %rcon.ip $2-
    /rcon.challenge %rcon.ip %rcon.port
  }    
  else { msg $nick You are not an bot operator.
  }
}

on *:TEXT:!port *:?:{ 
  if ($nick isop %channel) {
    msg $nick PORT set to: $2
    set %rcon.port $2-
    /rcon.challenge %rcon.ip %rcon.port
  }    
  else { msg $nick You are not an bot operator.
  }
}

on *:TEXT:!logs:?:{ 
  if ($nick isop %channel) {
    rconoff
    rconon
    msg $nick Logs restarting in 5 seconds.
  }    
  else { msg $nick You are not an bot operator.
  }
}

on *:TEXT:!lo3:?:{
  if ($nick isop %channel) {
    lo3
  }
}

on *:TEXT:!rconpw *:?:{ 
  if ($nick isop %channel) {
    msg $nick This does not change RCON password. It updates the RCON password that is set in the bot.
    msg $nick RCON password updated to: $2
    set %rcon.password $2-
    /rcon.password %rcon.password
  }    
  else { msg $nick You are not an bot operator.
  }
}

on *:TEXT:!disable:%channel:{
  if ($nick isop %channel) {
    if ( !%disable ) {
      set %disable 1
      endfordisable
      msg %channel 3» 14Pug has been disabled by $nick
      topicdis
      halt
    }
    if ( %disable = 1 ) { 
      notice $nick Already disabled.
    }
  }
}

on *:TEXT:!enable:%channel:{
  if ($nick isop %channel) {
    unset %disable 
    topicend
  }
}
on *:TEXT:!login:?:{
  if ($nick isop %channel) { /authserv auth NUMB3RS greece1 | msg $nick Logged in as NUMB3RS }
  else {
    msg $nick you not an bot operator.
  }
}

on *:TEXT:*:#espug:{
  var %secs 3, %lines = 5
  hinc $+(-mu,%secs) $nick count
  if $hget($nick,count) >= %lines { kick # $nick Detected %lines lines in %secs secs | .hdel -sw $nick count }
}


on *:NOTICE:*:#espug:{
  var %secs 3, %lines = 5
  hinc $+(-mu,%secs) $nick count
  if $hget($nick,count) >= %lines { kick # $nick Detected %lines lines in %secs secs | .hdel -sw $nick count }
}

on *:load:{
  set %rcon.says 0
  set %scorebot 0
  set %rcon.myip $ip
}

alias lo3 {
  set %rcon.says 0
  set %extra 0
  rcon mp_autoteambalance 0 
  rcon mp_buytime 0.25 
  rcon mp_consistency 1 
  rcon mp_startmoney 800
  rcon mp_c4timer 35 
  rcon mp_flashlight 1 
  rcon mp_forcechasecam 2 
  rcon mp_forcecamera 2 
  rcon mp_freezetime 6 
  rcon mp_limitteams 0 
  rcon mp_friendlyfire 1 
  rcon mp_maxrounds 0 
  rcon mp_roundtime 1.75
  rcon mp_timelimit 0 
  rcon sv_alltalk 0 
  rcon sv_gravity 800 
  rcon sv_maxupdaterate 101 
  rcon sv_minupdaterate 20 
  rcon sv_maxrate 25000
  rcon allow_spectators 3 
  .timer 1 1 rcon sv_restart 1
  .timer 1 1 rcon say Live on Three Restarts! 
  .timer 1 3 rcon sv_restart 1
  .timer 1 3 rcon say Live on Two Restarts!
  .timer 1 5 rcon sv_restart 3
  .timer 1 5 rcon say Live on One Restart!
  .timer 1 9 rcon say LIVE LIVE LIVE!! GLHF!!
  .timer 1 10 rcon say Support #espug
  .timer 1 10 set %scorebot 1
}