Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Persistent
- ; #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- CheckForGTAV()
- ModFolder := A_WorkingDir . "\Mods"
- Mods := []
- ServerList := ""
- SelectedServer := ""
- SelectedMods := ""
- IniRead, RagePath, config.ini,path , path
- IniRead, SelectedServer, config.ini,path , server
- IniRead, SelectedMods, config.ini,path , mods
- if(SelectedMods != "")
- {
- SelectedMods := StrSplit(SelectedMods, "<")
- }
- if(RagePath != "")
- {
- ServerFolder := RagePath . "\client_resources"
- }
- vPressMe := ""
- gExecFunc := ""
- Gui, Show,w600 h400, Mod Launcher
- Start()
- Return
- Start()
- {
- global
- Gui, Add, Text,y29 x5, Servers
- Gui, Add, Text,y29 x305, Mods
- Gui, Add, Button, vSelectRAGE gExecFunc y0 x0, Select RAGE Folder
- Gui, Add, ListView, vServerList gSelectedServerEvent h300 w290 y45 x5 AltSubmit,Name
- Gui, Add, ListView, vModList h300 w290 y45 x305 Checked,Mod
- Loop %ModFolder%\*.*,2
- {
- Mods.Push(A_LoopFileName)
- RowNumber := LV_Add(Check,A_LoopFileName)
- Loop % SelectedMods.MaxIndex()
- {
- selectedMod := SelectedMods[A_Index]
- if(selectedMod == A_LoopFileName)
- {
- LV_Modify(RowNumber, "Check")
- }
- }
- }
- Gui, Add, Button, vStartGame gExecFunc y365 x5, Start game
- Gui, Add, Button, vSaveSelectedMods gExecFunc y365 x487, Save selected mods
- Gui, Add, Text, y370 x75, Server:
- Gui, Add, Text, vSelectedServer y370 x112 w350, Click on the server
- if(RagePath != "")
- {
- LoadServers()
- }
- if(SelectedServer != "null")
- {
- GuiControl,,SelectedServer,%SelectedServer%
- }
- ; The variable name will be the name of the function you wish to execute
- ; Always set the gLabel to the "universal" function executor
- Gui, Show
- }
- SelectedServerEvent:
- If (A_GuiEvent = "Normal")
- {
- LV_GetText(RowText, A_EventInfo)
- if(RowText != "Mod" && RowText != "Name" )
- {
- global SelectedServer := RowText
- GuiControl,,SelectedServer,%RowText%
- IniWrite, %SelectedServer%, config.ini,path , server
- }
- }
- Return
- ; Here is my function executor
- ExecFunc:
- %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!
- Return
- SelectRage()
- {
- AssignPath()
- LoadServers()
- }
- StartGame()
- {
- global
- if(CheckValues())
- {
- LoadSelectedMods()
- StartLauncher()
- }
- }
- LoadSelectedMods()
- {
- global
- Mods := []
- Gui, ListView, ModList
- RowNumber := 0 ; This causes the first loop iteration to start the search at the top of the list.
- Loop % LV_GetCount()
- {
- LV_GetText(RetrievedText, A_Index)
- RowChecked := LV_GetNext(A_Index - 1, "Checked" )
- If ( A_Index = RowChecked )
- {
- Mods.Push(RetrievedText)
- RowChecked := True
- }
- Else
- {
- RowChecked := False
- }
- }
- }
- SaveSelectedMods()
- { global
- Gui, ListView, ModList
- RowNumber := 0 ; This causes the first loop iteration to start the search at the top of the list.
- SelectedMods := []
- SelectedModsString := ""
- Loop % LV_GetCount()
- {
- LV_GetText(RetrievedText, A_Index)
- RowChecked := LV_GetNext(A_Index - 1, "Checked" )
- If ( A_Index = RowChecked )
- {
- SelectedMods.Push(RetrievedText)
- if(SelectedModsString == "")
- {
- SelectedModsString = %RetrievedText%
- }
- else
- {
- SelectedModsString = %SelectedModsString%<%RetrievedText%
- }
- RowChecked := True
- }
- Else
- {
- RowChecked := False
- }
- }
- IniWrite, %SelectedModsString%, config.ini,path , mods
- Gui, ListView, ServerList
- }
- LoadServers()
- {
- global
- Gui, ListView, ServerList
- Loop %ServerFolder%\*.*,2
- {
- (A_LoopFileName)
- LV_Add("", A_LoopFileName)
- }
- }
- AssignPath()
- {
- global
- MsgBox, Select RAGE MP Installation folder
- FileSelectFolder, SelectedRagePath,,,Select RAGE MP folder
- if(SelectedRagePath != "")
- {
- RagePath := SelectedRagePath
- ServerFolder := RagePath . "\client_resources"
- IniWrite, %RagePath%, config.ini,path , path
- }
- }
- StartLauncher()
- {
- global RagePath
- global Mods
- global ModFolder
- global SelectedServer
- for index, element in Mods ; Enumeration is the recommended approach in most cases.
- {
- MovingModFolder := ModFolder . "\" . element
- MovingModPath := RagePath . "\client_resources\" . SelectedServer . "\dlcpacks\"
- FileCopyDir, %MovingModFolder%, %MovingModPath%\%element% , 1
- }
- WorkDir := A_ScriptDir
- SetWorkingDir %RagePath%
- UpdaterExe := RagePath . "\updater.exe"
- Run *RunAs updater.exe
- SetWorkingDir %WorkDir%
- SetTimer, WaitForUpdater, 5000
- Return
- }
- WaitForUpdater:
- CheckForGTAV()
- if(ProcessExist("ragemp_v.exe"))
- {
- SetTimer, CheckForUpdater, 5000
- SetTimer, WaitForUpdater, OFF
- }
- Return
- CheckForUpdater:
- If !ProcessExist("ragemp_v.exe")
- {
- global RagePath
- global Mods
- global ModFolder
- global SelectedServer
- for index, element in Mods ; Enumeration is the recommended approach in most cases.
- {
- MovingModFolder := ModFolder . "\" . element
- MovingModPath := RagePath . "\client_resources\" . SelectedServer . "\dlcpacks\"
- FileCopyDir, %MovingModFolder%, %MovingModPath%\%element% , 1
- }
- ExitApp
- }
- Return
- CheckForGTAV()
- {
- If ProcessExist("GTA5.exe")
- {
- ExitApp
- }
- }
- ProcessExist(Name)
- {
- Process,Exist,%Name%
- Return Errorlevel
- }
- CheckValues()
- {
- global SelectedServer
- global RagePath
- if(SelectedServer = "" or RagePath = "")
- {
- MsgBox, You didn't set RAGE MP folder or select the server
- Return false
- }
- Return true
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement