HL:CS/CS:S Server Query (HLCS) — File Browser

HLCSCSSServerQueryHLCSv4.1 / HLCSCSSServerQueryHLCSv4.1 / HLCS / HLCS.mrc

HLCS.mrc — 37.5 KB — Download this file

on *:LOAD:{
  if (%HLCS.SteamLoc == $null) { set %HLCS.SteamLoc $sfile(C:/,Find your steam.exe) }
  if (%HLCS.SteamLoc == $null) { echo 7 -a HLCS: For this script to work properly, you must locate your Steam.exe and your Cstrike directory }
}
;;Menu Stuff;;
menu status,channel,query,nick {
  -
  HLCS Main:if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
  Server Finder: if (!$dialog(HLSQ)) { dialog -dm HLSQ HLSQ }
  Player Finder: if (!$dialog(HLPQ)) { dialog -dm HLPQ HLPQ }
  Text Commands
  .On:set %HLCS.TextInfo on
  .Off:set %HLCS.TextInfo off
  Unload HLCS
  .Unload:HLCS.unload
  -
}
;;MDX Stuff;;
alias mdx_fullpath { return $shortfn($scriptdirmdx\MDX.DLL) }
alias mdx_view { return $shortfn($scriptdirmdx\VIEWS.MDX) }
alias mdx { dll $mdx_fullpath $1- }
alias mdxinit {
  dll $mdx_fullpath SetMircVersion $version
  dll $mdx_fullpath MarkDialog $dname
}

;;Dialog Stuff;;
dialog HLCS {
  title "HL:CS/CS:S Server Query"
  size -1 -1 188 141
  option dbu
  combo 1, 5 4 133 50, size edit drop
  button "Search", 2, 148 4 37 11, default flat
  text "Server Name:", 3, 5 22 33 8
  text "IP Address:", 4, 9 37 29 8
  text "Map:", 5, 26 52 12 8
  text "Game:", 6, 22 67 16 8
  text "Active/Max:", 7, 9 82 29 8
  text "Password:", 8, 13 97 25 8
  text "Secure:", 9, 68 97 18 8
  text "Ping:", 10, 116 97 12 8
  edit "", 11, 41 21 145 10, read
  edit "", 12, 41 36 68 10, read
  edit "", 13, 41 51 68 10, read
  edit "", 14, 41 66 67 10, read
  edit "", 15, 41 81 22 10, read
  edit "", 16, 41 96 22 10, read
  edit "", 17, 89 96 22 10, read
  edit "", 18, 130 96 22 10, read
  button "Join", 19, 6 127 37 12, flat
  button "Refresh", 20, 53 127 37 12, flat
  button "Close", 21, 99 127 37 12, flat
  button "Players >>", 22, 144 127 37 12, flat
  icon 23, 127 41 50 46
  list 24, 0 143 188 50, size
  box "", 25, 0 121 188 20
  box "", 26, 0 -2 188 19
  box "", 27, 0 13 188 97
  box "Map Screenshot", 28, 123 34 59 57
  check "Auto Retry", 34, 26 112 37 10
  box "", 36, 0 106 86 19
  text "Made by noname: Version 4.1", 37, 101 113 72 8
  box "", 38, 85 106 103 19
  menu "Menu", 30
  item "Player Finder", 31, 30
  item "Server Finder", 32, 30
  item "View Favorites", 39, 30
  item "Add Favorite", 40, 30
  item "Clear Ip History", 33, 30
}
dialog HLPQ {
  title "HL:CS/CS:S Player Finder"
  size -1 -1 187 120
  option dbu
  edit "", 1, 3 5 138 11
  button "Search", 2, 146 5 37 11, default flat
  box "", 3, 1 -2 184 21
  box "", 5, 1 15 184 87
  list 4, 2 20 181 79, size
  box "", 6, 1 98 184 21
  button "Join", 8, 5 104 37 12, flat
  button "Get Info", 9, 51 104 37 12, flat
  button "Close", 10, 143 104 37 12, flat
  button "Copy IP", 12, 97 104 37 12, flat
  menu "Menu", 7
  item "Server Finder", 11, 7
}
dialog HLSQ {
  title "HL:CS/CS:S Server Finder"
  size -1 -1 187 120
  option dbu
  edit "", 1, 3 5 138 11
  button "Search", 2, 147 5 37 11, default flat
  box "", 3, 1 -2 185 21
  box "", 5, 1 15 185 87
  list 4, 2 20 182 79, size
  box "", 6, 1 98 185 21
  menu "Menu", 7
  button "Join", 8, 5 104 37 12, flat
  button "Get Info", 9, 75 104 37 12, flat
  button "Close", 10, 144 104 37 12, flat
  item "Player Finder", 11, 7
}
dialog Fav {
  title "Favorites"
  size -1 -1 194 92
  option dbu
  list 1, 2 3 189 66, size
  button "Get Info", 2, 2 76 37 12, flat
  button "Add", 3, 40 76 37 12, flat
  button "Edit", 4, 78 76 37 12, flat
  button "Delete", 5, 116 76 37 12, flat
  box "", 6, 0 -2 194 74
  box "", 7, 0 68 194 24
  button "Close", 11, 154 76 37 12, flat
  menu "Menu", 8
  item "Server Finder", 9, 8
  item "Player Finder", 10, 8
}
dialog EditFav {
  title "Edit Server"
  size -1 -1 162 91
  option dbu
  box "Information", 1, 2 0 159 71
  text "Server Description:", 2, 6 10 47 8
  edit "", 3, 54 9 105 25, multi autovs vsbar
  text "IP Address:", 4, 6 35 29 8
  edit "", 5, 37 34 64 10
  text "(Include port below)", 6, 103 35 50 8
  edit "", 7, 37 57 103 10
  text "Game:", 8, 17 59 17 8
  box "", 9, 2 69 159 22
  edit "", 10, 37 45 28 10, limit 5
  text "(Example 27015)", 11, 67 46 45 8
  button "Save", 12, 24 75 37 12, flat default
  button "Cancel", 13, 64 75 37 12, flat ok cancel
}
dialog HLCSPw { 
  title "PW" 
  size -1 -1 75 50 
  option dbu 
  edit "", 1, 12 16 50 10 
  text "Enter Password", 2, 18 6 50 10 
  button "Connect", 3, 6 32 27 9, default flat
  button "Close", 4, 43 32 25 9, flat
} 
dialog HLCSar {
  title "Auto-Retry"
  size -1 -1 87 75
  option dbu
  text "Current Players:", 1, 10 7 40 8
  text "Current Ping:", 2, 17 18 33 8
  edit "", 3, 52 6 23 10, read
  edit "", 4, 52 17 23 10, read
  text "Join when there is:", 5, 10 29 46 8
  edit "", 6, 9 39 23 10
  text "Slot(s) available", 7, 35 40 38 8
  button "Join Now", 8, 2 60 37 12, flat
  box "Manual controls", 10, 0 52 86 23
  button "Close", 11, 46 60 37 12, flat
  box "Auto-Retry", 9, 0 -1 86 53
}

on *:dialog:HLCS:init:0:{
  mdx SetMircVersion $version
  mdx MarkDialog $dname
  mdx SetControlMDX $dname 24 ListView report grid > $mdx_view
  did -i hlcs 24 1 headerdims 190:1 50:2 120:3
  did -i hlcs 24 1 headertext Player $+ $chr(9) $+ Score $+ $chr(9) $+ Time
  var %i 0
  while (%i < $lines($shortfn($scriptdirrservers.txt))) {
    inc %i
    did -a HLCS 1 $read($shortfn($scriptdirrservers.txt),%i)
  }
}
on *:dialog:hlcs:sclick:2:{
  if ($gettok(%HLCS.AddFav,1,32)) { if ($input(Still trying to contact favorite server... $+ $crlf $+ Try again in $timer(ADDFAVORITETIMER).secs Seconds,o)) { dialog -v HLCS | halt } }
  if (!$read($shortfn($scriptdirrservers.txt),w,* $+ $did(HLCS,1) $+ *)) {
    write $shortfn($scriptdir) $+ rservers.txt $did(HLCS,1)
  }
  set %HLCS.add2combo 1
  var %i 0
  while (%i < $did(HLCS,1).lines) {
    inc %i
    if (* $+ $did(HLCS,1) $+ * iswm $did(HLCS,1,%i)) {
      set %HLCS.add2combo 0
    }
  }
  if (%HLCS.add2combo == 1) {
    did -a HLCS 1 $did(HLCS,1)
  }
  unset %HLCS.add2combo
  HLCSquery
}
on *:dialog:hlcs:sclick:19:{
  if ($did(HLCS,34).state == 1) {
    if (!$dialog(HLCSar)) { dialog -dm HLCSar HLCSar }
    halt
  }
  if ($gettok($did(HLCS,15),1,47) == $gettok($did(HLCS,15),2,47)) {
    if (!$dialog(HLCSar)) { dialog -dm HLCSar HLCSar }
    halt
  }
  if (%HLCS.PWProt == $true) {
    if (!$dialog(HLCSPw)) { dialog -dm HLCSPw HLCSPw }
  }
  else {
    HLCSAddrJoin
  }
}
on *:dialog:hlcs:sclick:20:{
  HLCSquery
}
on *:dialog:hlcs:sclick:21:{
  dialog -dx HLCS HLCS
}
on *:dialog:hlcs:sclick:22:{
  if ($did(HLCS,22) == Players >>) {
    dialog -sb hlcs $dialog(hlcs).x $dialog(hlcs).y 188 204
    did -a HLCS 22 Players <<
  }
  else {
    dialog -sb hlcs $dialog(hlcs).x $dialog(hlcs).y 188 152
    did -a HLCS 22 Players >>
  }
}
on *:dialog:hlcs:menu:31:{
  if (!$dialog(HLPQ)) { dialog -dm HLPQ HLPQ }
}
on *:dialog:hlcs:menu:32:{
  if (!$dialog(HLSQ)) { dialog -dm HLSQ HLSQ }
}
on *:dialog:hlcs:menu:33:{
  write -c $shortfn($scriptdirrservers.txt)
  did -r HLCS 1
}
on *:dialog:HLCS:menu:39:{
  if (!$dialog(Fav)) { dialog -dm Fav Fav }
}
on *:dialog:HLCS:menu:40:{
  if ($did(HLCS,12)) { 
    if ($did(HLCS,1) != $did(HLCS,12)) {
      AddFav $iif($?="The IP in the search bar and the IP in the query results differ. Which one do you want to add? 1 for IP in search bar and 2 for the other IP" == 1,$did(HLCS,1),$did(HLCS,12))
    }
    AddFav $did(HLCS,12)
  }
}
on *:dialog:HLCSPw:sclick:3:{
  HLCSAddrJoin $did(HLCSPw,1)
  dialog -x HLCSPw HLCSPw
}
on *:dialog:HLCSPw:sclick:4:{
  unset %HLCS.PWprot
  unset %HLCS.JoinFromServer
  dialog -x HLCSPw HLCSPw
}
on *:dialog:HLSQ:init:0:{
  mdxinit
  mdx SetControlMDX $dname 4 ListView report single grid > $mdx_view
  did -i $dname 4 1 headerdims 180 140 90 80 60
  did -i $dname 4 1 headertext Server Name $chr(9) IP $chr(9) Map $chr(9) Game type $chr(9) Players 
}
on *:dialog:HLSQ:sclick:2:{
  did -r HLSQ 4
  HLCSServerQ
}
on *:dialog:HLSQ:dclick:4:{
  if ($did(HLSQ,4).seltext) { 
    if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
    did -i HLCS 1 0 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-4,32)
    if (!$read($shortfn($scriptdirrservers.txt),w,* $+ $did(HLCS,1) $+ *)) {
      write $shortfn($scriptdir) $+ rservers.txt $did(HLCS,1)
    }
    set %HLCS.add2combo 1
    var %i 0
    while (%i < $did(HLCS,1).lines) {
      inc %i
      if (* $+ $did(HLCS,1) $+ * iswm $did(HLCS,1,%i)) {
        set %HLCS.add2combo 0
      }
    }
    if (%HLCS.add2combo == 1) {
      did -a HLCS 1 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-4,32)
    }
    unset %HLCS.add2combo
    dialog -v HLCS
    HLCSquery
  }
}
on *:dialog:HLSQ:sclick:8:{
  if ($did(HLSQ,4).seltext) { 
    if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
    did -i HLCS 1 0 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-4,32)
    if (!$read($shortfn($scriptdirrservers.txt),w,* $+ $did(HLCS,1) $+ *)) {
      write $shortfn($scriptdir) $+ rservers.txt $did(HLCS,1)
    }
    set %HLCS.add2combo 1
    var %i 0
    while (%i < $did(HLCS,1).lines) {
      inc %i
      if (* $+ $did(HLCS,1) $+ * iswm $did(HLCS,1,%i)) {
        set %HLCS.add2combo 0
      }
    }
    if (%HLCS.add2combo == 1) {
      did -a HLCS 1 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-4,32)
    }
    unset %HLCS.add2combo
    if ($did(HLCS,34).state == 1) {
      if (!$dialog(HLCSar)) { dialog -dm HLCSar HLCSar }
      halt
    }
    if ($gettok($did(HLCS,15),1,47) == $gettok($did(HLCS,15),2,47)) {
      if (!$dialog(HLCSar)) { dialog -dm HLCSar HLCSar }
      halt
    }
    if (%HLCS.PWProt == $true) {
      HLCSquery
      if (!$dialog(HLCSPw)) { dialog -dm HLCSPw HLCSPw }
    }
    else {
      set %HLCS.JoinFromServer $true
      HLCSquery
      .timerHLCSTimer3 1 3 dialog -t HLSQ HL:CS/CS:S Server Finder
      dialog -t HLSQ HL:CS/CS:S Server Finder - Preparing to join
      .timerHLCSTimer2 1 2 HLCSAddrJoin
    }
  }
}
on *:dialog:HLSQ:sclick:9:{
  if ($did(HLSQ,4).seltext) { 
    if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
    did -i HLCS 1 0 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-4,32)
    if (!$read($shortfn($scriptdirrservers.txt),w,* $+ $did(HLCS,1) $+ *)) {
      write $shortfn($scriptdir) $+ rservers.txt $did(HLCS,1)
    }
    set %HLCS.add2combo 1
    var %i 0
    while (%i < $did(HLCS,1).lines) {
      inc %i
      if (* $+ $did(HLCS,1) $+ * iswm $did(HLCS,1,%i)) {
        set %HLCS.add2combo 0
      }
    }
    if (%HLCS.add2combo == 1) {
      did -a HLCS 1 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-4,32)
    }
    unset %HLCS.add2combo
    dialog -v HLCS
    HLCSquery
  }
}
on *:dialog:HLSQ:sclick:10:{
  dialog -x HLSQ HLSQ
}
on *:dialog:HLSQ:menu:11:{
  if (!$dialog(HLPQ)) { dialog -dm HLPQ HLPQ }
}

on *:dialog:Fav:init:0:{
  mdxinit
  mdx SetControlMDX $dname 1 ListView report single grid > $mdx_view
  did -i $dname 1 1 headerdims 148 140 85
  did -i $dname 1 1 headertext Server Name $chr(9) IP $chr(9) Game Type
  var %i 0
  while (%i < $lines($shortfn($scriptdirFavServers.txt))) {
    inc %i
    did -a Fav 1 $gettok($read($shortfn($scriptdirFavServers.txt),%i),1,15) $chr(9) $gettok($read($shortfn($scriptdirFavServers.txt),%i),2,15) $chr(9) $gettok($read($shortfn($scriptdirFavServers.txt),%i),3,15)
  }
}
on *:dialog:Fav:dclick:1:{
  if ($did(Fav,1).seltext) {
    if ($dialog(HLCS)) { dialog -x HLCS HLCS }
    dialog -dm HLCS HLCS
    if ($gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-1,32) == Source) {
      did -i HLCS 1 0 $gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-3,32)
    }
    else {
      did -i HLCS 1 0 $gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-2,32)
    }
    HLCSQuery
  }
}
on *:dialog:Fav:sclick:2:{
  if ($did(Fav,1).seltext) {
    if ($dialog(HLCS)) { dialog -x HLCS HLCS }
    dialog -dm HLCS HLCS
    if ($gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-1,32) == Source) {
      did -i HLCS 1 0 $gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-3,32)
    }
    else {
      did -i HLCS 1 0 $gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-2,32)
    }
    HLCSQuery
  }
}
on *:dialog:Fav:sclick:3:{
  addFav $?="Enter the IP to the favorite you wish to add"
}
on *:dialog:Fav:sclick:4:{
  if ($did(Fav,1).seltext) {
    set %HLCS.FavCache $replace($remove($did(Fav,1).seltext,0 +fs 0 0 0 ), 	+ 0 0 0 ,$chr(15))
    if (!$dialog(EditFav)) { dialog -dm EditFav EditFav }
  }
}
on *:dialog:Fav:sclick:5:{
  if ($did(Fav,1).seltext) {
    var %i 0
    while (%i < $lines($shortfn($scriptdirFavServers.txt))) {
      inc %i
      if (* $+ $gettok($remove($did(Fav,1).seltext, 	+ 0 0 0),-2,32) $+ * iswm $read($shortfn($scriptdirFavServers.txt),%i)) {
        write -dl $+ %i $shortfn($scriptdirFavServers.txt)
      }
    }
    dialog -x Fav Fav
    dialog -dm Fav Fav
  }
}
on *:dialog:Fav:menu:9:{
  if (!$dialog(HLSQ)) { dialog -dm HLSQ HLSQ }
}
on *:dialog:Fav:menu:10:{
  if (!$dialog(HLPQ)) { dialog -dm HLPQ HLPQ }
}
on *:dialog:Fav:sclick:11:{
  dialog -x Fav Fav
}

on *:dialog:EditFav:init:0:{
  did -a EditFav 3 $gettok(%HLCS.FavCache,1,15)
  did -a EditFav 5 $gettok($gettok(%HLCS.FavCache,2,15),1,58)
  did -a EditFav 7 $gettok(%HLCS.FavCache,3,15)
  did -a EditFav 10 $gettok($gettok(%HLCS.FavCache,2,15),2,58)
}
on *:dialog:EditFav:sclick:12:{
  if ($did(EditFav,3)) && ($did(EditFav,5)) && ($did(EditFav,7)) && ($did(EditFav,10)) {
    var %i 0
    while (%i < $lines($shortfn($scriptdirFavServers.txt))) {
      inc %i
      if (* $+ $remove($gettok(%HLCS.FavCache,2,15),$chr(32)) $+ * iswm $read($shortfn($scriptdirFavServers.txt),%i)) {
        write -l $+ %i $shortfn($scriptdirFavServers.txt) $did(EditFav,3) $+ $chr(15) $+ $did(EditFav,5) $+ : $+ $did(EditFav,10) $+ $chr(15) $+ $did(EditFav,7)
      }
    }
    dialog -x EditFav EditFav
    dialog -x Fav Fav
    dialog -dm Fav Fav
  }
}
on *:dialog:HLCSar:init:0:{
  set %HLCS.ar $true
  HLCSQuery
  .timerHLCSARTIMER 0 3 { HLCSarCheck }
}
on *:dialog:HLCSar:sclick:8:{
  .timerHLCSARTIMER off
  unset %HLCS.ar
  if (%HLCS.PWprot == $true) { dialog -dm HLCSpw HLCSpw | halt }
  dialog -x HLCSar HLCSar
  HLCSAddrJoin
}
on *:dialog:HLCSar:sclick:11:{
  .timerHLCSARTIMER off
  unset %HLCS.ar
  dialog -x HLCSar HLCSar
}
on *:dialog:HLCSar:close:*:{
  .timerHLCSARTIMER off
  unset %HLCS.ar
  dialog -x HLCSar HLCSar
}
on *:dialog:HLPQ:init:0:{
  mdxinit
  mdx SetControlMDX $dname 4 ListView report single grid > $mdx_view
  did -i $dname 4 1 headerdims 180 140
  did -i $dname 4 1 headertext Player Name $chr(9) IP 
}
on *:dialog:HLPQ:sclick:2:{
  did -r HLPQ 4
  HLCSpf
}
on *:dialog:HLPQ:dclick:4:{
  if ($did(HLPQ,4).seltext) {
    if ($dialog(HLCS)) { dialog -x HLCS HLCS }
    dialog -dm HLCS HLCS
    if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
    did -i HLCS 1 0 $gettok($remove($did(HLPQ,4).seltext,	+ 0 0 0),-1,32)
    if (!$read($shortfn($scriptdirrservers.txt),w,* $+ $did(HLCS,1) $+ *)) {
      write $shortfn($scriptdir) $+ rservers.txt $did(HLCS,1)
    }
    set %HLCS.add2combo 1
    var %i 0
    while (%i < $did(HLCS,1).lines) {
      inc %i
      if (* $+ $did(HLCS,1) $+ * iswm $did(HLCS,1,%i)) {
        set %HLCS.add2combo 0
      }
    }
    if (%HLCS.add2combo == 1) {
      did -a HLCS 1 $gettok($remove($did(HLPQ,4).seltext,	+ 0 0 0),-1,32)
    }
    unset %HLCS.add2combo
    HLCSQuery
  }
}
on *:dialog:HLPQ:sclick:8:{
  if ($did(HLPQ,4).seltext) {
    if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
    did -i HLCS 1 0 $gettok($remove($did(HLPQ,4).seltext,	+ 0 0 0),-1,32)
    if (!$read($shortfn($scriptdirrservers.txt),w,* $+ $did(HLCS,1) $+ *)) {
      write $shortfn($scriptdir) $+ rservers.txt $did(HLCS,1)
    }
    set %HLCS.add2combo 1
    var %i 0
    while (%i < $did(HLCS,1).lines) {
      inc %i
      if (* $+ $did(HLCS,1) $+ * iswm $did(HLCS,1,%i)) {
        set %HLCS.add2combo 0
      }
    }
    if (%HLCS.add2combo == 1) {
      did -a HLCS 1 $gettok($remove($did(HLSQ,4).seltext,	+ 0 0 0),-1,32)
    }
    unset %HLCS.add2combo
    if ($did(HLCS,34).state == 1) {
      if (!$dialog(HLCSar)) { dialog -dm HLCSar HLCSar }
      halt
    }
    if ($gettok($did(HLCS,15),1,47) == $gettok($did(HLCS,15),2,47)) {
      if (!$dialog(HLCSar)) { dialog -dm HLCSar HLCSar }
      halt
    }
    if (%HLCS.PWProt == $true) {
      HLCSquery
      if (!$dialog(HLCSPw)) { dialog -dm HLCSPw HLCSPw }
    }
    else {
      set %HLCS.JoinFromServer $true
      HLCSquery
      .timerHLCSTimer3 1 3 dialog -t HLPQ HL:CS/CS:S Server Finder
      dialog -t HLPQ HL:CS/CS:S Player Finder - Preparing to join
      .timerHLCSTimer2 1 2 HLCSAddrJoin
    }
  }
}
on *:dialog:HLPQ:sclick:10:{
  dialog -x HLPQ HLPQ
}
on *:dialog:HLPQ:menu:11:{
  if (!$dialog(HLSQ)) { dialog -dm HLSQ HLSQ }
}
on *:dialog:HLPQ:sclick:12:{
  if ($did(HLPQ,4).seltext) { clipboard $gettok($did(HLPQ,4).seltext,-1,32) }
}
;;UDP Stuff;;
alias -l HLCSPinger {  
  if ($1) {
    set %HLCS.PINGip $1
  }
  sockudp -k HLCS.ping $gettok(%HLCS.PINGip,1,58) $gettok(%HLCS.PINGip,2,58) 每每每每USource Engine Query
  set %HLCS.ticks $ticks 
}
on *:udpread:HLCS.ping:{ 
  sockread &temp 
  breplace &temp 0 160 
  inc %HLCS.PingCounter
  set %HLCS.ping [ $+ [ %HLCS.PingCounter ] ] $calc($ticks - %HLCS.ticks)
  if (%HLCS.PingCounter >= 3) && (%HLCS.ar == $true) { did -r HLCSar 4 | did -a HLCSar 4 $round($calc($calc(%HLCS.ping1 + %HLCS.ping2 + %HLCS.ping3) / 3),0) }
  if (%HLCS.PingCounter >= 3) { did -r HLCS 18 | did -a HLCS 18 $round($calc($calc(%HLCS.ping1 + %HLCS.ping2 + %HLCS.ping3) / 3),0) | unset %HLCS.Ping* | unset %HLCS.challenge | halt } 
  if (%HLCS.PingCounter <= 3) { HLCSPinger } 
} 
alias HLCSquery {
  set %i 0
  if ($gettok(%HLCS.AddFav,1,32) == $true) {
    set %HLCS.ip $gettok($gettok(%HLCS.AddFav,-1,32),1,58)
    set %HLCS.port $gettok($gettok(%HLCS.AddFav,-1,32),2,58)
    sockudp -k HLCS.addr %HLCS.ip %HLCS.port 每每每每TSource Engine Query
    halt
  }
  if ($gettok(%HLCS.infoReturn,1,32) == $true) {
    if (*.net* iswm $gettok(%HLCS.infoReturn,-1,32)) || (*.com* iswm $gettok(%HLCS.infoReturn,-1,32)) || (*.org* iswm $gettok(%HLCS.infoReturn,-1,32)) {
      set %HLCS.dns $true $iif($gettok($gettok(%HLCS.infoReturn,-1,32),2,58),$null,27015)
      .dns $gettok($gettok(%HLCS.infoReturn,-1,32),1,58)
      halt
    }
    .timerTIMEOUT 1 3 HLCSTimeout
    set %HLCS.ip $gettok($gettok(%HLCS.infoReturn,-1,32),1,58)
    set %HLCS.port $gettok($gettok(%HLCS.infoReturn,-1,32),2,58)
    sockudp -k HLCS.addr %HLCS.ip %HLCS.port 每每每每TSource Engine Query
    halt
  }
  if (*.net* iswm $did(HLCS,1)) || (*.com* iswm $did(HLCS,1)) || (*.org* iswm $did(HLCS,1)) {
    set %HLCS.dns $true $iif($gettok($did(HLCS,1),2,58),$gettok($did(HLCS,1),2,58),27015)
    .dns $gettok($did(HLCS,1),1,58) 
    .timerHLCSQuery 1 1 HLCSquery
    halt
  }
  if (!$isip($gettok($did(HLCS,1),1,58))) {
    dialog -t HLCS HL:CS/CS:S Server Query - Invalid IP
    halt
  }
  dialog -t HLCS HL:CS/CS:S Server Query - Searching
  .timerTIMEOUT 1 3 HLCSTimeout
  if (!$gettok($did(HLCS,1),2,58)) { did -i HLCS 1 0 $did(HLCS,1) $+ :27015 }
  set %HLCS.ip $gettok($did(HLCS,1),1,58)
  set %HLCS.port $gettok($did(HLCS,1),2,58)
  sockudp -k HLCS.addr %HLCS.ip %HLCS.port 每每每每TSource Engine Query
  set %HLCS.queried $false
  sockudp -k HLCS.playr %HLCS.ip %HLCS.port 每每每每USource Engine Query
}
on *:udpread:HLCS.addr:{ 
  sockread -f &info
  if (0 isin $bvar(&info,1,$bvar(&info,0))) {
    breplace &info 0 254
  }
  else { halt }
  if (Source !isin $bvar(&info,1,$bvar(&info,0)).text) {
    var %HLCS.tmp $mid($bvar(&info,1,$bvar(&info,0)).text,$calc($pos($bvar(&info,1,$bvar(&info,0)).text,每每每每m,1) +5),$len($bvar(&info,1,$bvar(&info,0)).text))
    if (镁 !isin $mid(%HLCS.tmp,1,1)) {
      if ($gettok(%HLCS.AddFav,1,32) == $true) {
        if (!$read($shortfn($scriptdirFavServers.txt),w,* $+ $gettok(%HLCS.AddFav,-1,32) $+ *)) {
          write $shortfn($scriptdirFavServers.txt) $replace($remove($gettok(%HLCS.tmp,2,254),$chr(13)),$chr(58),$chr(32)) $+ $chr(15) $+ $gettok(%HLCS.AddFav,-1,32) $+ $chr(15) $+ $gettok(%HLCS.tmp,5,254)
          if ($dialog(Fav)) { dialog -x Fav | dialog -dm Fav Fav }
        }
        else { echo 7 -a HLCS: Duplicate IP, not adding. }
        unset %HLCS.AddFav
        halt
      }
      if ($gettok(%HLCS.infoReturn,1,32) == $true) {
        msg $gettok(%HLCS.infoReturn,2,32) Name: $remove($gettok(%HLCS.tmp,2,254),$chr(13)) - IP: $gettok(%HLCS.infoReturn,-1,32) - Map: $gettok(%HLCS.tmp,3,254) - Game: $gettok(%HLCS.tmp,5,254) - Active/Max Players: $iif($asc($mid($gettok(%HLCS.tmp,6,254),2,1)) > 32,0/ $+ $asc($mid($gettok(%HLCS.tmp,5-6,254),16,1)), $asc($left($gettok(%HLCS.tmp,6,254),1)) $+ / $+ $asc($mid($gettok(%HLCS.tmp,6,254),2,1))) - PW: $iif($asc($mid($gettok(%HLCS.tmp,6,254),6,1)) == 1,Yes,No) - Secure: $iif($asc($left($right($gettok(%HLCS.tmp,6-7,254),2),1)) == 254,No,Yes)
        unset %HLCS.infoReturn
        .timerTIMEOUT off
        halt
      }
      var %i 11
      while (%i <= 17) {
        did -r HLCS %i
        inc %i
      }
      did -a HLCS 11 $remove($gettok(%HLCS.tmp,2,254),$chr(13))
      did -a HLCS 12 $did(HLCS,1)
      did -a HLCS 13 $gettok(%HLCS.tmp,3,254)
      did -a HLCS 14 $gettok(%HLCS.tmp,5,254)
      if ($asc($mid($gettok(%HLCS.tmp,6,254),2,1)) > 32) { did -a HLCS 15 0/ $+ $asc($mid($gettok(%HLCS.tmp,5-6,254),16,1)) }
      else { did -a HLCS 15 $asc($left($gettok(%HLCS.tmp,6,254),1)) $+ / $+ $asc($mid($gettok(%HLCS.tmp,6,254),2,1)) }
      if (%HLCS.ar == $true) { did -r HLCSar 3 | did -a HLCSar 3 $asc($left($gettok(%HLCS.tmp,6,254),1)) $+ / $+ $asc($mid($gettok(%HLCS.tmp,6,254),2,1)) }
      if ($asc($mid($gettok(%HLCS.tmp,6,254),6,1)) == 1) {
        set %HLCS.PWProt $true
        did -a HLCS 16 Yes
      }
      else {
        set %HLCS.PWProt $false
        did -a HLCS 16 No
      }
      did -a HLCS 17 $iif($asc($left($right($gettok(%HLCS.tmp,6-7,254),2),1)) == 254,No,Yes)
    }
  }
  else {
    var %HLCS.tmp $mid($bvar(&info,1,$bvar(&info,0)).text,7,$len($bvar(&info,1,$bvar(&info,0)).text))
    if ($gettok(%HLCS.AddFav,1,32) == $true) {
      if (!$read($shortfn($scriptdirFavServers.txt),w,* $+ $gettok(%HLCS.AddFav,-1,32) $+ *)) {
        echo -a $right($gettok(%HLCS.tmp,1,254),1) - $asc($right($gettok(%HLCS.tmp,1,254),1))
        write $shortfn($scriptdirFavServers.txt) $gettok(%HLCS.tmp,1,254) $+ $chr(15) $+ $gettok(%HLCS.AddFav,-1,32) $+ $chr(15) $+ $gettok(%HLCS.tmp,4,254)
        if ($dialog(Fav)) { dialog -x Fav | dialog -dm Fav Fav }
      }
      else { echo 7 -a HLCS: Duplicate IP, not adding. }
      unset %HLCS.AddFav
      halt
    }
    if ($gettok(%HLCS.infoReturn,1,32) == $true) {
      msg $gettok(%HLCS.infoReturn,2,32) Name: $gettok(%HLCS.tmp,1,254) - IP: $gettok(%HLCS.infoReturn,-1,32) - Map: $gettok(%HLCS.tmp,2,254) - Game: $gettok(%HLCS.tmp,4,254) - Active/Max Players: $iif($len($gettok(%HLCS.tmp,6,254)) == 1,$iif($asc($mid($gettok(%HLCS.tmp,5-6,254),2,1)) == 254,0,$ifmatch) $+ / $+ $iif($asc($mid($gettok(%HLCS.tmp,5-6,254),3,1)) == 254,0,$ifmatch), $asc($mid($gettok(%HLCS.tmp,6,254),1,1)) $+ / $+ $asc($mid($gettok(%HLCS.tmp,6,254),2,1))) - PW: $iif($asc($mid($gettok(%HLCS.tmp,7-8,254),3,1)) == 1,Yes,No) - Secure: $iif($asc($mid($gettok(%HLCS.tmp,7-8,254),4,1)) == 1,Yes,No)
      unset %HLCS.infoReturn
      .timerTIMEOUT off
      halt
    }
    var %i 11
    while (%i <= 17) {
      did -r HLCS %i
      inc %i
    }
    did -a HLCS 11 $gettok(%HLCS.tmp,1,254)
    did -a HLCS 12 $did(HLCS,1)
    did -a HLCS 13 $gettok(%HLCS.tmp,2,254)
    did -a HLCS 14 $gettok(%HLCS.tmp,4,254)
    if ($len($gettok(%HLCS.tmp,6,254)) == 1) { did -a HLCS 15 $iif($asc($mid($gettok(%HLCS.tmp,5-6,254),2,1)) == 254,0,$ifmatch) $+ / $+ $iif($asc($mid($gettok(%HLCS.tmp,5-6,254),3,1)) == 254,0,$ifmatch) }
    else { did -a HLCS 15 $asc($mid($gettok(%HLCS.tmp,6,254),1,1)) $+ / $+ $asc($mid($gettok(%HLCS.tmp,6,254),2,1)) }
    if (%HLCS.ar == $true) { 
      did -r HLCSar 3
      if ($len($gettok(%HLCS.tmp,6,254)) == 1) { did -a HLCSar 3 $iif($asc($mid($gettok(%HLCS.tmp,5-6,254),2,1)) == 254,0,$ifmatch) $+ / $+ $iif($asc($mid($gettok(%HLCS.tmp,5-6,254),3,1)) == 254,0,$ifmatch) }
      else { did -a HLCSar 3 $asc($mid($gettok(%HLCS.tmp,6,254),1,1)) $+ / $+ $asc($mid($gettok(%HLCS.tmp,6,254),2,1)) }
    }
    if ($asc($mid($gettok(%HLCS.tmp,7-8,254),3,1)) == 1) {
      did -a HLCS 16 Yes
      set %HLCS.PWProt $true
    }
    else {
      did -a HLCS 16 No
      set %HLCS.PWProt $false
    }
    if ($asc($mid($gettok(%HLCS.tmp,7-8,254),4,1)) == 1) {
      did -a HLCS 17 Yes
    }
    else {
      did -a HLCS 17 No
    }
  }
  if ($exists($shortfn($scriptdir) $+ mappic\ $+ $did(HLCS,13) $+ .bmp) == $true) {
    did -g HLCS 23 $shortfn($scriptdir) $+ mappic\ $+ $did(HLCS,13) $+ .bmp 
  }
  else { 
    did -g HLCS 23 $shortfn($scriptdir) $+ mappic\ $+ Error.bmp
  }
  if ($len($did(HLCS,23)) < 5) { did -g HLCS 23 $shortfn($scriptdir) $+ mappic\ $+ Error.bmp }
  .timerTIMEOUT off
  HLCSPinger $did(HLCS,1)
  dialog -t HLCS HL:CS/CS:S Server Query - Done
  :error
  write $shortfn($scriptdir) $+ errorlog.txt Error is: $error
  halt
}
on *:udpread:HLCS.playr: { 
  if ($sockerr > 0) return 
  did -r HLCS 24
  sockread &temp 
  if ($count($bvar(&temp,6,6),$chr(32)) == 3) && (%HLCS.queried != $true) { sockudp -k HLCS.playr %HLCS.ip %HLCS.port 每每每每U $+ $bvar(&temp,6,4).text | set %HLCS.queried $true | halt }
  breplace &temp 255 0 
  var %client_start = 8, %i = 0, %clients = $bvar(&temp,6)
  while (%i <= %clients) { 
    var %client = $bvar(&temp,%client_start,$calc($bfind(&temp,%client_start,0) - %client_start)).text
    var %frag = $bvar(&temp,$calc($bfind(&temp,%client_start,0) + 1),1) 
    var %time32 = $bvar(&temp,$calc($bfind(&temp,%client_start,%frag 0 0 0) + $iif(%frag,4,5)),4) 
    var %client_start = $calc($bfind(&temp,%client_start,%frag 0 0 0) + $iif(%frag,9,10)) 
    if (%client != $null) { did -a HLCS 24 %client $chr(9) %frag $chr(9) $dur2($unfloat(%time32)) }
    inc %i 
  }
}
alias HLCSpf { 
  if ($gettok(%HLCS.playerReturn,1,32) == $true) {
    set %HLCS.pf $gettok(%HLCS.playerReturn,3,32)
    if ($chr(32) isin %HLCS.pf) { set %HLCS.pf $replace(%HLCS.pf,$chr(32),+) } 
    unset %HLCS.pc
    sockopen HLCS.pf cstiger.de 80
    halt
  }
  if ($did(HLPQ,1) == $null) { 
    dialog -t HLPQ HL:CS/CS:S Player Finder - Enter a player
  } 
  else { 
    set %HLCS.pf $did(HLPQ,1)
    if ($chr(32) isin %HLCS.pf) { set %HLCS.pf $replace(%HLCS.pf,$chr(32),+) } 
    dialog -t HLPQ HL:CS/CS:S Player Finder - Searching
    unset %HLCS.pc
    sockopen HLCS.pf cstiger.de 80 
  } 
} 
on *:sockopen:HLCS.pf:{ 
  sockwrite -n $sockname GET /search?player= $+ %HLCS.pf $+ &game=all HTTP/1.1 
  sockwrite -n $sockname Host: www.cstiger.de
  sockwrite -n $sockname Connection: close 
  sockwrite -n $sockname $crlf 
} 
on *:sockread:HLCS.pf:{ 
  if ($sockerr) { 
    echo -a Error. 
  } 
  else { 
    var %gameplayer
    sockread %gameplayer
    if (</td><td><font face="helvetica,arial,sans-serif"> isin %gameplayer) { 
      if ($gettok(%HLCS.playerReturn,1,32) == $true) {
        inc %HLCS.pc
        if (%HLCS.pc <= 5) {
          .timer $+ %HLCS.pc 1 %HLCS.pc .notice $gettok(%HLCS.playerReturn,2,32) Nick: $nohtml($remove($gettok(%gameplayer,3-4,62),</td,1&nbsp,;)) - IP: $gettok($remove($nohtml(%gameplayer),1&nbsp;,&nbsp;),-5,32)
        }
        halt
      }
      inc %HLCS.pc
      did -a HLPQ 4 $nohtml($remove($gettok(%gameplayer,3-4,62),</td,1&nbsp,;)) $chr(9) $gettok($remove($nohtml(%gameplayer),1&nbsp;,&nbsp;),-5,32) 
      dialog -t HLPQ HL:CS/CS:S Player Finder - %HLCS.pc $iif(%HLCS.pc == 1,Result,Results) 
    } 
  } 
} 
on *:SOCKCLOSE:HLCS.pf:{
  if ($gettok(%HLCS.playerReturn,1,32) == $true) && (%HLCS.pc == $null) || (%HLCS.pc == 0) {
    .notice $gettok(%HLCS.playerReturn,2,32) No results
    unset %HLCS.playerReturn
    unset %HLCS.pc
    halt
  }
  if ($gettok(%HLCS.playerReturn,1,32) == $true) && (%HLCS.pc > 0) {
    .notice $gettok(%HLCS.playerReturn,2,32) Showing top 5 results.
    unset %HLCS.playerReturn
    unset %HLCS.pc
    halt
  }
  if (%HLCS.pc == $null) || (%HLCS.pc == 0) { dialog -t HLPQ HL:CS/CS:S Player Finder - 0 Results }
}
alias HLCSServerQ { 
  if ($gettok(%HLCS.serverReturn,1,32) == $true) {
    set %HLCSServerQ.name $gettok(%HLCS.serverReturn,3,32)
    if ($chr(32) isin %HLCSServerQ.name) { set %HLCSServerQ.name $replace(%HLCSServerQ.name,$chr(32),+) } 
    unset %HLCSServerQ.amount
    sockopen HLCSServerQ cstiger.de 80
    halt 
  }
  if ($did(HLSQ,1) == $null) { 
    dialog -t HLSQ HL:CS/CS:S Server Finder - Enter a server
  } 
  else { 
    set %HLCSServerQ.name $did(HLSQ,1)
    if ($chr(32) isin %HLCSServerQ.name) { set %HLCSServerQ.name $replace(%HLCSServerQ.name,$chr(32),+) } 
    unset %HLCSServerQ.amount
    dialog -t HLSQ HL:CS/CS:S Server Finder - Searching
    sockopen HLCSServerQ cstiger.de 80 
  } 
} 
on *:sockopen:HLCSServerQ:{ 
  sockwrite -n $sockname GET /search?sType=server&server= $+ %HLCSServerQ.name $+ &submitButton=&count=100&game=all HTTP/1.1 
  sockwrite -n $sockname Host: www.cstiger.de
  sockwrite -n $sockname Connection: close 
  sockwrite -n $sockname $crlf 
} 
on *:sockread:HLCSServerQ:{ 
  if ($sockerr) { 
    echo -a Error. 
  } 
  else { 
    var %hlserver 
    sockread %hlserver    
    if (<td><font face="helvetica,arial,sans-serif"> isin %hlserver) && (suche !isin $nohtml(%hlserver)) { 
      if ($gettok(%HLCS.serverReturn,1,32) == $true) {
        inc %HLCSServerQ.amount
        if (%HLCSServerQ.amount <= 5) { 
          var %HLCSServerQ.results $remove($nohtml(%hlserver),&nbsp,;,$gettok($nohtml(%hlserver),-1,32))
          .timer $+ %HLCSServerQ.amount 1 %HLCSServerQ.amount .notice $gettok(%HLCS.serverReturn,2,32) Server: $remove(%HLCSServerQ.results,$gettok(%HLCSServerQ.results,-1,32),$gettok(%HLCSServerQ.results,-2,32),$gettok(%HLCSServerQ.results,-3,32),$gettok(%HLCSServerQ.results,-4,32)) - IP: $gettok(%HLCSServerQ.results,-4,32) - Map: $gettok(%HLCSServerQ.results,-2,32) - Game: $gettok(%HLCSServerQ.results,-3,32) - Active/Max: $gettok(%HLCSServerQ.results,-1,32)
        }
        halt
      }
      inc %HLCSServerQ.amount
      var %HLCSServerQ.results $remove($nohtml(%hlserver),&nbsp,;,$gettok($nohtml(%hlserver),-1,32))
      did -a HLSQ 4 $remove(%HLCSServerQ.results,$gettok(%HLCSServerQ.results,-1,32),$gettok(%HLCSServerQ.results,-2,32),$gettok(%HLCSServerQ.results,-3,32),$gettok(%HLCSServerQ.results,-4,32)) $chr(9) $gettok(%HLCSServerQ.results,-4,32) $chr(9) $gettok(%HLCSServerQ.results,-2,32) $chr(9) $gettok(%HLCSServerQ.results,-3,32) $chr(9) $gettok(%HLCSServerQ.results,-1,32)
      dialog -t HLSQ HL:CS/CS:S Server Finder - %HLCSServerQ.amount Results
    } 
  } 
}
on *:SOCKCLOSE:HLCSServerQ:{
  if (%HLCSServerQ.amount == $null) && ($gettok(%HLCS.serverReturn,1,32) == $true) { .notice $gettok(%HLCS.serverReturn,2,32) 0 Results | unset %HLCS.serverReturn | unset %HLCSServerQ.amount | halt }
  if ($gettok(%HLCS.serverReturn,1,32) == $true) && (%HLCSServerQ.amount > 0) { .notice $gettok(%HLCS.serverReturn,2,32) Showing top 5 results. | unset %HLCS.serverReturn | unset %HLCSServerQ.amount | halt }
  if (%HLCSServerQ.amount == $null) { dialog -t HLSQ HL:CS/CS:S Server Finder - 0 Results }
}

;;Aliases;;

;;isip by jaytea @ #script @ gamesurge;;
alias isip return $regex($1,/^(?:(25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?1)$/)
;;

alias AddFav {
  if (!$isip($gettok($1,1,58))) {
    echo 7 -a HLCS: Invalid IP provided, not adding favorite.
    halt
  }
  else if (!$1) {
    echo 7 -a HLCS: No IP provided, not adding favorite.
    halt
  }
  else {
    set %HLCS.AddFav $true $1 $+ $iif($gettok($1,2,58),$null,:27015)
    .timerADDFAVORITETIMER 1 7 unset %HLCS.AddFav
    HLCSQuery
  }
}
alias HLCS {
  if (!$dialog(HLCS)) { dialog -dm HLCS HLCS }
  else { 
    dialog -x HLCS HLCS
    dialog -dm HLCS HLCS
  }
  did -i HLCS 1 0 $1
  HLCSQuery
}
alias HLCSarCheck {
  HLCSQuery
  if ($did(HLCSar,6)) {
    if ($did(HLCSar,6) <= $calc($gettok($did(HLCSar,3),2,47) - $gettok($did(HLCSar,3),1,47))) {
      if (%HLCS.PWProt == $true) {
        if (!$dialog(HLCSPw)) { dialog -dm HLCSPw HLCSPw }
        .timerHLCSARTIMER off
        unset %HLCS.ar
        dialog -x HLCSar HLCSar
        halt
      }
      .timerHLCSARTIMER off
      unset %HLCS.ar
      dialog -x HLCSar HLCSar
      HLCSAddrJoin
    }
  }
}
alias -l HLCSTimeout {
  if ($gettok(%HLCS.infoReturn,1,32) == $true) { msg $gettok(%HLCS.infoReturn,2,32) Server ( $+ $gettok(%HLCS.infoReturn,-1,32) $+ ) Timed Out | unset %HLCS.infoReturn | halt }
  dialog -t HLCS HL:CS/CS:S Server Query - Server Timed Out
} 
;; Converts from float32 (4 bytes) to decimal - by noob
; usage: $unfloat(<float32>)
alias -l unfloat {
  if ($gettok($1,4,32) >= 100) return error
  var %x 4, %f , %b
  while (%x > 1) { %f = %f $+ $base($gettok($1,%x,32),10,2,8) | dec %x }
  var %m 1 $+ $mid(%f,10,23) , %e $calc($base($mid(%f,2,8),2,10) -127) , %x 24
  while (%x > 0) { dec %x | %b = $calc( %b + 2 ^ $calc(%x + %e) * $mid( %m , $calc(24 - %x) , 1 ) ) }
  return $calc(%b / 2^23)
}
alias -l dur2 {
  if ($1 == $null) return $null
  var %dur2 = $duration($1-)
  if (wks isin %dur2) var %dur2 = $replace(%dur2,wks,w)
  if (wk isin %dur2) var %dur2 = $replace(%dur2,wk,w)
  if (days isin %dur2) var %dur2 = $replace(%dur2,days,d)
  if (day isin %dur2) var %dur2 = $replace(%dur2,day,d)
  if (hrs isin %dur2) var %dur2 = $replace(%dur2,hrs,h)
  if (hr isin %dur2) var %dur2 = $replace(%dur2,hr,h)
  if (mins isin %dur2) var %dur2 = $replace(%dur2,mins,m)
  if (min isin %dur2) var %dur2 = $replace(%dur2,min,m)
  if (secs isin %dur2) var %dur2 = $replace(%dur2,secs,s)
  if (sec isin %dur2) var %dur2 = $replace(%dur2,sec,s)
  return %dur2
}
alias -l HLCSAddrJoin {
  if (%HLCS.SteamLoc == $null) {
    set %HLCS.SteamLoc $sfile(C:\,Locate you steam.exe)
    if (%HLCS.SteamLoc == $null) { echo 7 -a HLCS: You MUST locate your Steam.exe | halt }
  }
  if (%HLCS.PWProt == $true) { 
    if (*Source* iswm $did(HLCS,14)) { 
      run -p %HLCS.SteamLoc -applaunch 240 -console +connect $did(HLCS,1) +password $1
    }
    if ($did(HLCS,14) == Counter-strike) || ($did(HLCS,14) == cstrike) {
      run -p %HLCS.SteamLoc -applaunch 10 -console +connect $did(HLCS,1) +password $1
    }
  }
  else {
    if ($did(HLCS,14) == Counter-strike) || ($did(HLCS,14) == cstrike) {
      run -p %HLCS.SteamLoc -applaunch 10 -console +connect $did(HLCS,1)
    }
    if (*Source* iswm $did(HLCS,14)) { 
      run -p %HLCS.SteamLoc -applaunch 240 -console +connect $did(HLCS,1)
    }
  }
}
alias -l HLCS.unload {
  unset %HLCS*
  if ($dialog(HLCS)) { dialog -x HLCS HLCS }
  if ($dialog(HLPQ)) { dialog -x HLPQ HLPQ }
  if ($dialog(HLSQ)) { dialog -x HLSQ HLSQ }
  if ($dialog(Fav)) { dialog -x Fav Fav }
  if ($dialog(Editfav)) { dialog -x Editfav Editfav }
  if ($dialog(HLCSpw)) { dialog -x HLCSpw HLCSpw }
  if ($dialog(HLCSar)) { dialog -x HLCSar HLCSar }
  echo -a HLCS Unloaded
  .unload -rs HLCS.mrc
}
alias nohtml {
  var %tmp, %ignore = $regsub($1-,/(<[^>]+>)/g,$chr(32),%tmp)
  return $replace(%tmp,&nbsp;,$null)
}
;;DNS Stuff;;
on *:DNS:{
  if ($gettok(%HLCS.dns,1,32) == $true) {
    var %n $dns(0)
    if ($dns(%n).ip != $null) {
      if ($gettok(%HLCS.infoReturn,1,32) == $true) { set %HLCS.infoReturn $true $gettok(%HLCS.infoReturn,2,32) $dns(%n).ip $+ : $+ $iif($gettok($gettok(%HLCS.infoReturn,-1,32),2,58),$ifmatch,27015) | HLCSQuery | unset %HLCS.dns | halt }
      else { did -i HLCS 1 0 $dns(%n).ip $+ : $+ $gettok(%HLCS.dns,-1,32) }
    }
    else {
      if ($gettok(%HLCS.infoReturn,1,32) == $true) { msg $gettok(%HLCS.infoReturn,2,32) Could not resolve IP }
      else { if ($timer(HLCSQuery)) { dialog -t HLCS HL:CS/CS:S Server Query - Could not resolve server | .timerHLCSQuery off } }
    }
    unset %HLCS.dns
  }
}
;;EVENTS;;

on *:TEXT:[hlcs]server *:#:{
  if (%HLCS.TextInfo == on) {
    if (%HLCS.Flood. [ $+ [ $nick ] ] == 3) { .notice $nick You have reached your flood limit, please wait a while before trying again. | inc -u45 %HLCS.Flood. [ $+ [ $nick ] ] | halt }
    else { inc -u45 %HLCS.Flood [ $+ [ $nick ] ] }
    if ($timer($gettok(%HLCS.serverReturn,2,32))) { .notice $nick Please, 1 search at a time. | halt }
    if ($2) {
      set %HLCS.serverReturn $true $nick $2-
    }
    HLCSServerQ
  }
}
on *:TEXT:[hlcs]player *:#:{
  if (%HLCS.TextInfo == on) {
    if (%HLCS.Flood. [ $+ [ $nick ] ] == 3) { .notice $nick You have reached your flood limit, please wait a while before trying again. | inc -u45 %HLCS.Flood. [ $+ [ $nick ] ] | halt }
    else { inc -u45 %HLCS.Flood. [ $+ [ $nick ] ] }
    if ($timer($gettok(%HLCS.playerReturn,2,32))) { .notice $nick Please, 1 search at a time. | halt }
    if ($2) {
      set %HLCS.playerReturn $true $nick $2-
      HLCSpf
    }
  }
}
on *:TEXT:[hlcs]info *:#:{
  if (%HLCS.TextInfo == on) {
    if (%HLCS.Flood. [ $+ [ $nick ] ] == 3) { .notice $nick You have reached your flood limit, please wait a while before trying again. | inc -u45 %HLCS.Flood. [ $+ [ $nick ] ] | halt }
    else { inc -u45 %HLCS.Flood. [ $+ [ $nick ] ] }
    if (!$isip($gettok($2,1,58))) {
      if (*.org* iswm $2) || (*.com* iswm $2) || (*.net* iswm $2) { 
        if (*http://* !iswm $2) && (*www.* !iswm $2) {
          set %HLCS.dns $true 
          set %HLCS.infoReturn $true $chan $2
          .dns $gettok($2,1,58)
          halt
        }
      }
      msg $chan Invalid IP
    }
    else if ($2) {
      set %HLCS.infoReturn $true $chan $2 $+ $iif($gettok($2,2,58),$null,:27015)
      HLCSquery
    }
  }
}