Minecraft Server restart script help Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Gohirro
Posts: 5
Joined: 25 Oct 2021, 12:33

Minecraft Server restart script help

Post by Gohirro » 25 Oct 2021, 12:52

My batch file "server.bat" is on my desktop. I am trying to setup a script that will say in the chat "Server restarting in x minutes" and then have it run the script at a specific time. I am looking for something similar to what I have done with a command to record video in OBS at 20 minute intervals using the following commands:

Code: Select all

; Always run as admin
if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}
toggle	:= 0
return

F3::Suspend
return

F2::
	toggle	:= !toggle
	if (toggle = 1){
		ControlSend, , {F1}, ahk_exe obs64.exe
		SetTimer, toggleLabel, 900000
	}else
		SetTimer, toggleLabel, Off
return

toggleLabel:
	ControlSend, , {F1}, ahk_exe obs64.exe
	Sleep, 2000
	ControlSend, , {F1}, ahk_exe obs64.exe
return
[Mod edit: [code][/code] tags added.]

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Minecraft Server restart script help

Post by mikeyww » 25 Oct 2021, 14:39

Code: Select all

Run, notepad
WinWaitActive, ahk_exe notepad.exe
Loop, % seconds := 5 {
 ControlSend, Edit1, % "{Text}Seconds remaining: " seconds + 1 - A_Index "`n", ahk_exe notepad.exe
 Sleep, 1000
}
Run, notepad
MsgBox, 262192, Done, Boom!

Gohirro
Posts: 5
Joined: 25 Oct 2021, 12:33

Re: Minecraft Server restart script help

Post by Gohirro » 25 Oct 2021, 15:30

mikeyww wrote:
25 Oct 2021, 14:39

Code: Select all

Run, notepad
WinWaitActive, ahk_exe notepad.exe
Loop, % seconds := 5 {
 ControlSend, Edit1, % "{Text}Seconds remaining: " seconds + 1 - A_Index "`n", ahk_exe notepad.exe
 Sleep, 1000
}
Run, notepad
MsgBox, 262192, Done, Boom!
I will try that, thank you.

Gohirro
Posts: 5
Joined: 25 Oct 2021, 12:33

Re: Minecraft Server restart script help

Post by Gohirro » 25 Oct 2021, 15:42

mikeyww wrote:
25 Oct 2021, 14:39

Code: Select all

Run, notepad
WinWaitActive, ahk_exe notepad.exe
Loop, % seconds := 5 {
 ControlSend, Edit1, % "{Text}Seconds remaining: " seconds + 1 - A_Index "`n", ahk_exe notepad.exe
 Sleep, 1000
}
Run, notepad
MsgBox, 262192, Done, Boom!
Thats pretty close to what Im striving for. What I am trying to is the opposite, where it says in chat "Server restarting in 5 minutes" and then sending the /save-all and /stop commands and then waiting 1-2 minutes before starting up the server.bat file located in the desktop, all in a loop with a 4 hr sleep timer (that part I know is easy enough with "sleep, x") I feel silly for asking, I know Im pretty close to it but its been a few years since I played around with autohotkey scripts.

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Minecraft Server restart script help

Post by mikeyww » 25 Oct 2021, 18:04

This is just a demonstration. You would need to add those commands wherever you want them to happen, adjust the intervals, etc. At least for me, your description is too vague to code directly.

Gohirro
Posts: 5
Joined: 25 Oct 2021, 12:33

Re: Minecraft Server restart script help

Post by Gohirro » 28 Oct 2021, 18:18

Okay so I got some stuff figured out with backing up the folder and starting the server after restarting. The only thing left I am looking for is how to send a command to the command prompt window (running server.bat) to do the /save-all and /stop commands.

User avatar
mikeyww
Posts: 26601
Joined: 09 Sep 2014, 18:38

Re: Minecraft Server restart script help

Post by mikeyww » 28 Oct 2021, 18:51

That's a different question. I do not know enough about Minecraft to answer it. Others here or in the gaming forum may know.

Gohirro
Posts: 5
Joined: 25 Oct 2021, 12:33

Re: Minecraft Server restart script help  Topic is solved

Post by Gohirro » 29 Oct 2021, 11:26

I managed to get it to work, I had to use a different scripting program and use that with task scheduler.

Post Reply

Return to “Gaming Help (v1)”