Advertisement
Guest User

Untitled

a guest
Jul 6th, 2020
612
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  2. #Persistent
  3. ; #Warn ; Enable warnings to assist with detecting common errors.
  4. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  5. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  6. CheckForGTAV()
  7. ModFolder := A_WorkingDir . "\Mods"
  8. Mods := []
  9. ServerList := ""
  10. SelectedServer := ""
  11. SelectedMods := ""
  12. IniRead, RagePath, config.ini,path , path
  13. IniRead, SelectedServer, config.ini,path , server
  14. IniRead, SelectedMods, config.ini,path , mods
  15. if(SelectedMods != "")
  16. {
  17. SelectedMods := StrSplit(SelectedMods, "<")
  18. }
  19. if(RagePath != "")
  20. {
  21. ServerFolder := RagePath . "\client_resources"
  22. }
  23. vPressMe := ""
  24. gExecFunc := ""
  25. Gui, Show,w600 h400, Mod Launcher
  26. Start()
  27. Return
  28.  
  29. Start()
  30. {
  31. global
  32. Gui, Add, Text,y29 x5, Servers
  33. Gui, Add, Text,y29 x305, Mods
  34. Gui, Add, Button, vSelectRAGE gExecFunc y0 x0, Select RAGE Folder
  35. Gui, Add, ListView, vServerList gSelectedServerEvent h300 w290 y45 x5 AltSubmit,Name
  36. Gui, Add, ListView, vModList h300 w290 y45 x305 Checked,Mod
  37. Loop %ModFolder%\*.*,2
  38. {
  39. Mods.Push(A_LoopFileName)
  40. RowNumber := LV_Add(Check,A_LoopFileName)
  41. Loop % SelectedMods.MaxIndex()
  42. {
  43. selectedMod := SelectedMods[A_Index]
  44. if(selectedMod == A_LoopFileName)
  45. {
  46. LV_Modify(RowNumber, "Check")
  47. }
  48. }
  49. }
  50. Gui, Add, Button, vStartGame gExecFunc y365 x5, Start game
  51. Gui, Add, Button, vSaveSelectedMods gExecFunc y365 x487, Save selected mods
  52. Gui, Add, Text, y370 x75, Server:
  53. Gui, Add, Text, vSelectedServer y370 x112 w350, Click on the server
  54. if(RagePath != "")
  55. {
  56. LoadServers()
  57. }
  58. if(SelectedServer != "null")
  59. {
  60. GuiControl,,SelectedServer,%SelectedServer%
  61. }
  62. ; The variable name will be the name of the function you wish to execute
  63. ; Always set the gLabel to the "universal" function executor
  64. Gui, Show
  65. }
  66.  
  67.  
  68. SelectedServerEvent:
  69. If (A_GuiEvent = "Normal")
  70. {
  71. LV_GetText(RowText, A_EventInfo)
  72. if(RowText != "Mod" && RowText != "Name" )
  73. {
  74. global SelectedServer := RowText
  75. GuiControl,,SelectedServer,%RowText%
  76. IniWrite, %SelectedServer%, config.ini,path , server
  77. }
  78. }
  79. Return
  80.  
  81. ; Here is my function executor
  82. ExecFunc:
  83. %A_GuiControl%() ; %A_GUIControl% is the name of the variable that the control is associated with. Yet another example of Autohotkey's useful variables in code!
  84. Return
  85.  
  86. SelectRage()
  87. {
  88. AssignPath()
  89. LoadServers()
  90. }
  91.  
  92.  
  93. StartGame()
  94. {
  95. global
  96. if(CheckValues())
  97. {
  98. LoadSelectedMods()
  99. StartLauncher()
  100. }
  101. }
  102.  
  103. LoadSelectedMods()
  104. {
  105. global
  106. Mods := []
  107. Gui, ListView, ModList
  108. RowNumber := 0 ; This causes the first loop iteration to start the search at the top of the list.
  109. Loop % LV_GetCount()
  110. {
  111. LV_GetText(RetrievedText, A_Index)
  112. RowChecked := LV_GetNext(A_Index - 1, "Checked" )
  113. If ( A_Index = RowChecked )
  114. {
  115. Mods.Push(RetrievedText)
  116. RowChecked := True
  117. }
  118. Else
  119. {
  120. RowChecked := False
  121. }
  122. }
  123. }
  124.  
  125. SaveSelectedMods()
  126. { global
  127. Gui, ListView, ModList
  128. RowNumber := 0 ; This causes the first loop iteration to start the search at the top of the list.
  129. SelectedMods := []
  130. SelectedModsString := ""
  131. Loop % LV_GetCount()
  132. {
  133. LV_GetText(RetrievedText, A_Index)
  134. RowChecked := LV_GetNext(A_Index - 1, "Checked" )
  135. If ( A_Index = RowChecked )
  136. {
  137. SelectedMods.Push(RetrievedText)
  138. if(SelectedModsString == "")
  139. {
  140. SelectedModsString = %RetrievedText%
  141. }
  142. else
  143. {
  144. SelectedModsString = %SelectedModsString%<%RetrievedText%
  145. }
  146. RowChecked := True
  147. }
  148. Else
  149. {
  150. RowChecked := False
  151. }
  152. }
  153. IniWrite, %SelectedModsString%, config.ini,path , mods
  154. Gui, ListView, ServerList
  155. }
  156.  
  157. LoadServers()
  158. {
  159. global
  160. Gui, ListView, ServerList
  161. Loop %ServerFolder%\*.*,2
  162. {
  163. (A_LoopFileName)
  164. LV_Add("", A_LoopFileName)
  165. }
  166. }
  167.  
  168.  
  169. AssignPath()
  170. {
  171. global
  172. MsgBox, Select RAGE MP Installation folder
  173. FileSelectFolder, SelectedRagePath,,,Select RAGE MP folder
  174. if(SelectedRagePath != "")
  175. {
  176. RagePath := SelectedRagePath
  177. ServerFolder := RagePath . "\client_resources"
  178. IniWrite, %RagePath%, config.ini,path , path
  179. }
  180. }
  181.  
  182.  
  183. StartLauncher()
  184. {
  185. global RagePath
  186. global Mods
  187. global ModFolder
  188. global SelectedServer
  189.  
  190. for index, element in Mods ; Enumeration is the recommended approach in most cases.
  191. {
  192. MovingModFolder := ModFolder . "\" . element
  193. MovingModPath := RagePath . "\client_resources\" . SelectedServer . "\dlcpacks\"
  194. FileCopyDir, %MovingModFolder%, %MovingModPath%\%element% , 1
  195. }
  196.  
  197. WorkDir := A_ScriptDir
  198. SetWorkingDir %RagePath%
  199. UpdaterExe := RagePath . "\updater.exe"
  200. Run *RunAs updater.exe
  201. SetWorkingDir %WorkDir%
  202. SetTimer, WaitForUpdater, 5000
  203. Return
  204. }
  205.  
  206. WaitForUpdater:
  207. CheckForGTAV()
  208. if(ProcessExist("ragemp_v.exe"))
  209. {
  210. SetTimer, CheckForUpdater, 5000
  211. SetTimer, WaitForUpdater, OFF
  212. }
  213. Return
  214.  
  215. CheckForUpdater:
  216. If !ProcessExist("ragemp_v.exe")
  217. {
  218. global RagePath
  219. global Mods
  220. global ModFolder
  221. global SelectedServer
  222.  
  223. for index, element in Mods ; Enumeration is the recommended approach in most cases.
  224. {
  225. MovingModFolder := ModFolder . "\" . element
  226. MovingModPath := RagePath . "\client_resources\" . SelectedServer . "\dlcpacks\"
  227. FileCopyDir, %MovingModFolder%, %MovingModPath%\%element% , 1
  228. }
  229. ExitApp
  230. }
  231. Return
  232.  
  233.  
  234. CheckForGTAV()
  235. {
  236. If ProcessExist("GTA5.exe")
  237. {
  238. ExitApp
  239. }
  240. }
  241.  
  242. ProcessExist(Name)
  243. {
  244. Process,Exist,%Name%
  245. Return Errorlevel
  246. }
  247.  
  248. CheckValues()
  249. {
  250. global SelectedServer
  251. global RagePath
  252. if(SelectedServer = "" or RagePath = "")
  253. {
  254. MsgBox, You didn't set RAGE MP folder or select the server
  255. Return false
  256. }
  257. Return true
  258. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement