Advertisement
Guest User

Untitled

a guest
Oct 16th, 2016
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 4.59 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=favicon.ico
  3. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  4. #cs ----------------------------------------------------------------------------
  5.  
  6.  AutoIt Version: 3.3.12.0
  7.  Author:         Neon
  8.  
  9.  
  10. #ce ----------------------------------------------------------------------------
  11.  
  12. #include <Array.au3>
  13. #include <String.au3>
  14. #include <File.au3>
  15.  
  16. #include <ButtonConstants.au3>
  17. #include <EditConstants.au3>
  18. #include <GUIConstantsEx.au3>
  19. #include <ProgressConstants.au3>
  20. #include <StaticConstants.au3>
  21. #include <WindowsConstants.au3>
  22.  
  23. $path_steam = IniRead("data.ini", "settings", "counterstrike", "Please select a folder!")
  24. $path_winrar = IniRead("data.ini", "settings", "winrar", "Please select a folder!")
  25. $url = "http://fastdl.unloze.com/css_ze/maps/"
  26.  
  27. $found = True
  28. $running = False
  29.  
  30.  
  31. Opt("GUIOnEventMode", 1)
  32. $Form1 = GUICreate("Unloze Mappack by Neon", 491, 163, 197, 130)
  33. GUISetFont(10, 400, 0, "Segoe UI")
  34. $Group1 = GUICtrlCreateGroup("Paths", 8, 8, 369, 89)
  35. $Input1 = GUICtrlCreateInput($path_steam, 16, 32, 241, 25)
  36. GUICtrlSetState(-1, $GUI_DISABLE)
  37. $Button1 = GUICtrlCreateButton("CS:S Path", 272, 32, 91, 25)
  38. $Input2 = GUICtrlCreateInput($path_winrar, 16, 64, 241, 25)
  39. GUICtrlSetState(-1, $GUI_DISABLE)
  40. $Button2 = GUICtrlCreateButton("WinRar Path", 272, 64, 91, 25)
  41. GUICtrlCreateGroup("", -99, -99, 1, 1)
  42. $Button3 = GUICtrlCreateButton("Start", 384, 56, 99, 41)
  43. GUICtrlSetFont(-1, 12, 800, 0, "Segoe UI")
  44. $Button4 = GUICtrlCreateButton("Unloze.com", 384, 16, 99, 33)
  45. $Progress1 = GUICtrlCreateProgress(8, 112, 478, 17)
  46. $Label2 = GUICtrlCreateLabel("...", 8, 136, 477, 21)
  47. GUISetState(@SW_SHOW)
  48.  
  49. GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")
  50. GUICtrlSetOnEvent($Button1, "_Steam")
  51. GUICtrlSetOnEvent($Button2, "_WinRar")
  52. GUICtrlSetOnEvent($Button3, "_Start")
  53. GUICtrlSetOnEvent($Button4, "_Unloze")
  54.  
  55. While 1
  56.  
  57.     If $running Then
  58.  
  59.         _Main()
  60.  
  61.     ElseIf Not $running Then
  62.  
  63.         Sleep(300)
  64.  
  65.     EndIf
  66.  
  67. WEnd
  68.  
  69. Func _Steam()
  70.  
  71.     $path_steam = FileSelectFolder("Select your Counterstrike folder (The folder with hl2.exe in it)", "C:") & "\cstrike\download\maps"
  72.  
  73.     If $path_steam = "\cstrike\download\maps" Then
  74.         MsgBox(0,"Error", "Please select a folder!")
  75.         $path_steam = "Please select a folder!"
  76.     EndIf
  77.  
  78.     GUICtrlSetData($Input1, $path_steam)
  79.  
  80. EndFunc   ;==>_Steam
  81.  
  82. Func _WinRar()
  83.  
  84.     $path_winrar = FileSelectFolder("Select your WinRar folder (The folder with WinRar.exe in it)", "C:") & "\WinRar.exe"
  85.  
  86.     If $path_winrar = "\WinRar.exe" Then
  87.         MsgBox(0,"Error", "Please select a folder!")
  88.         $path_winrar = "Please select a folder!"
  89.     EndIf
  90.  
  91.     GUICtrlSetData($Input2, $path_winrar)
  92. EndFunc   ;==>_WinRar
  93.  
  94. Func _Start()
  95.  
  96.     If $path_steam = "Please select a folder!" or $path_winrar = "Please select a folder!" Then
  97.         MsgBox(0,"Error!", "You did not select a valid path!")
  98.         _exit()
  99.     EndIf
  100.  
  101.  
  102.     IniWrite("data.ini", "settings", "counterstrike", $path_steam)
  103.     IniWrite("data.ini", "settings", "winrar", $path_winrar)
  104.  
  105.     $running = True
  106.  
  107. EndFunc   ;==>_Start
  108.  
  109. Func _Main()
  110.  
  111.     $raw_code_hex = InetRead($url)
  112.     $raw_code = _HexToString($raw_code_hex)
  113.     $array_online = _StringBetween(StringTrimLeft($raw_code, StringInStr($raw_code, 'disabled/</a>')), '<a href="', '.bz2">')
  114.     $length_online = Ubound($array_online) - 1
  115.     $array_local = _FileListToArray($path_steam)
  116.     $length_local = Ubound($array_local) - 1
  117.  
  118.     For $i = 0 To $length_online
  119.  
  120.         $found = False
  121.  
  122.         For $j = 0 To $length_local
  123.  
  124.             If StringCompare($array_online[$i], $array_local[$j]) = 0 Then
  125.                 $found = True
  126.             EndIf
  127.  
  128.         Next
  129.  
  130.             If Not $found Then
  131.                 _Download($array_online[$i])
  132.             EndIf
  133.  
  134.     Next
  135.  
  136.     $running = False
  137.  
  138.     MsgBox(64,"Finished","All Missing maps got downloaded and extracted!")
  139.  
  140. EndFunc   ;==>_Main
  141.  
  142. Func _Download($name)
  143.  
  144.     GUICtrlSetData($Label2, "Downloading:  " & $name & ".bz2")
  145.  
  146.     $FileSize_online = InetGetSize($url & $name & ".bz2")
  147.     InetGet($url & $name & ".bz2" , $name & ".bz2", 0, 1)
  148.  
  149.     While 1
  150.  
  151.     $FileSize_local = FileGetSize($name & ".bz2")
  152.  
  153.     $Percent = $FileSize_local / $FileSize_online * 100
  154.     Sleep(100)
  155.     GUICtrlSetData($Progress1, $Percent)
  156.  
  157.     If $FileSize_local = $FileSize_online Then  ExitLoop
  158.  
  159.     WEnd
  160.  
  161.     Sleep(500)
  162.  
  163.  
  164.     GUICtrlSetData($Label2, "Extracting:  " & $name & ".bz2")
  165.  
  166.     RunWait('"' & $path_winrar & '"' & ' e ' & $name & '.bz2 ' & '"' & $path_steam & '"')
  167.  
  168.     Sleep(300)
  169.  
  170.     FileDelete($name & ".bz2")
  171.     GUICtrlSetData($Progress1, 0)
  172.  
  173. EndFunc   ;==>_Main
  174.  
  175. Func _exit()
  176.     Exit
  177. EndFunc   ;==>_exit
  178.  
  179. Func _Unloze()
  180.     ShellExecute("https://unloze.com/")
  181. EndFunc   ;==>_Unloze
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement