Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Creator: Doug4347/RedNeckSnailSpit
- ; Date: 12/02/2022 (DD/MM/YYYY)
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- procName := "gta_sa.exe"
- SettingsFile := A_MyDocuments . "\AutoHotkey\SAMP_FL\Settings.ini"
- chatlog := A_MyDocuments . "\GTA San Andreas User Files\SAMP\chatlog.txt"
- Menu, Tray, Tip, SAMP FL (No Script Running)
- Menu, Tray, Add, Add Character, AddCharGui
- FileCreateDir, % A_MyDocuments . "\AutoHotkey\SAMP_FL\"
- IniRead, CharacterCount, % SettingsFile, General, CharCount, 0
- If !CharacterCount
- Goto, AddCharGui
- Chars := Array()
- Loop, % CharacterCount
- {
- IniRead, host, % SettingsFile, Hosts, % A_Index, 0
- if !host
- {
- MsgBox, 16, Error, Character #%A_Index% has no Host Name. This will cause problems later on. Please delete your %SettingsFile% file (Located in %A_MyDocuments%\AutoHotkey\SAMP_Launcher\) and run the script again.
- ExitApp
- }
- IniRead, name, % SettingsFile, CharNames, % A_Index, 0
- if !name
- {
- MsgBox, 16, Error, Character #%A_Index% has no Name. This will cause problems later on. Please delete your %SettingsFile% file (Located in %A_WorkingDir%) and run the script again.
- ExitApp
- }
- IniRead, script, % SettingsFile, exe, % A_Index, 0
- if !script
- {
- MsgBox, 16, Error, Character #%A_Index% has no associated script/executable. This will cause problems later on. Please delete your %SettingsFile% file (Located in %A_WorkingDir%) and run the script again.
- ExitApp
- }
- Chars[A_Index] := Array()
- Chars[A_Index]["host"] := host
- Chars[A_Index]["name"] := name
- Chars[A_Index]["script"] := script
- }
- TrayTip, SAMP File Launcher, SAMP FL is now running. Registered characters: %CharacterCount%
- Loop,
- {
- Process, Wait, % procName
- ifExist, %chatlog%
- {
- FileGetTime, OriginalModTime, % chatlog, M
- NewModTime := OriginalModTime
- While (NewModTime = OriginalModTime)
- FileGetTime, NewModTime, % chatlog, M
- }
- i := 1
- Loop,
- {
- FileRead, Logs, % chatlog
- If (InStr(Logs, Chars[i]["host"]) and InStr(Logs, Chars[i]["name"]))
- {
- Run, % Chars[i]["script"]
- Menu, Tray, Tip, % "SAMP FL (Character: " . Chars[i]["name"] . ")"
- TrayTip, Script Launched, % "A file was launched when you logged into SAMP.`nHost Name: " . Chars[i]["host"] . "`nCahracter Name: " . Chars[i]["name"]
- Break
- }
- i += 1
- if !Chars[i]["host"]
- i := 1
- }
- Process, WaitClose, % procName
- Menu, Tray, Tip, SAMP FL (No Script Running)
- }
- AddCharGui:
- Gui, Add, Text,, Server Host Name
- Gui, Add, Edit, vServHostName w500
- Gui, Add, Text,, Character Name
- Gui, Add, Edit, vCharName w500
- Gui, Add, Text,, File to Execute
- Gui, Add, Edit, vExe w500
- Gui, Add, Button, gBrowse, Browse...
- Gui, Add, Button, gSubmitChar w500, Add Character
- Gui, Show,, Add New Character
- Return
- Browse:
- FileSelectFile, SelectedFile
- GuiControl,, Exe, %SelectedFile%
- Return
- SubmitChar:
- Gui, Submit, NoHide
- if (!ServHostName or !CharName or !Exe)
- {
- MsgBox, 16, Empty Fields, Please make sure to fill in all fields.
- Return
- }
- IniRead, CharacterCount, % SettingsFile, General, CharCount, 0
- IniWrite, % CharacterCount + 1, % SettingsFile, General, CharCount
- IniWrite, % ServHostName, % SettingsFile, Hosts, % CharacterCount + 1
- IniWrite, % CharName, % SettingsFile, CharNames, % CharacterCount + 1
- IniWrite, % Exe, % SettingsFile, exe, % CharacterCount + 1
- MsgBox, 64, Character Added, Successfully added %CharName% for server %ServHostName%
- Return
- GuiClose:
- Reload
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement