garrysmod server restarter

well its not lua, but i dont know where else to put

My server restarter.

Restarts the server.

For Windows 32/64 bit

put restarter.exe and restarter_config.ini to srcds.exe

edit the restarter_config.ini, change port and parameter to your own

please comment

thank you

[Download here (Yes you can trust me)](http://www.scripter192.bplaced.de/files/server restarter.zip)

For the guys who dont trust me:

Source Code (AutoIt v3):
[release]


 ATTENTION

You are not allowed to re-release this in any way.

 



#cs
Garrysmod Server restarter v. 1.1 by Deathmaker (aka Scripter192)

for Windows 32/64 bit

You are not allowed to re-release this in any way




#ce
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\..\..\..\Program Files\AutoIt3\Aut2Exe\Icons\SETUP12.ICO
#AutoIt3Wrapper_Compression=0
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("TrayMenuMode", 1)
Opt("TrayOnEventMode", 1)
$exit = TrayCreateItem("Beenden")
TrayItemSetOnEvent(-1, "_exit")
#include<inet.au3>
#include<string.au3>
UDPStartup()
HttpSetUserAgent("Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.1.8) Gecko/20100202 Firefox/3.5.8")
Global $pid
If Not FileExists("srcds.exe") Then
	MsgBox(0, "Error", "Place this executable in the server dir! (same as srcds.exe)")
	Exit
EndIf
If Not FileExists("restart_config.ini") Then
	MsgBox(0, "Error", "Config (restart_config.ini) not found!")
	Exit
EndIf

_log("Der Server restarter wurde gestartet!")

$pid = Run("srcds.exe " & IniRead("restart_config.ini", "Settings", "parameter", ""))
TrayTip("", "GMod server restarter by Deathmaker", 10)

AdlibRegister("udpcheck", 120000)


While 1
	Sleep(IniRead("restart_config.ini", "Settings", "crashchecktime", 5000))
	If WinExists("Engine Error") And WinGetProcess("Engine Error") = $pid Then
		$error = WinGetText("Engine Error")
		ProcessClose($pid)
		$pid = Run("srcds.exe " & IniRead("restart_config.ini", "Settings", "parameter", ""))
		TrayTip("", "Error. Restarting!", 10)
		_log("Error: " & $error & "   ... restarting")
	ElseIf WinExists("Microsoft Windows", "") And ProcessExists("WerFault.exe") Then
		$error = "Windows Error:  srcds.exe dont work anymore"
		ProcessClose("WerFault.exe")
		ProcessClose($pid)
		$pid = Run("srcds.exe " & IniRead("restart_config.ini", "Settings", "parameter", ""))
		TrayTip("", "Error. Restarting!", 10)
		_log("Error: " & $error & "   ...restarting")

	ElseIf WinExists("Sys_Error") And WinGetProcess("Sys_Error") = $pid Then
		$error = WinGetText("Sys_Error")
		ProcessClose($pid)
		$pid = Run("srcds.exe " & IniRead("restart_config.ini", "Settings", "parameter", ""))
		TrayTip("", "Error. Restarting!", 10)
		_log("Error: " & $error & "   ...restarting")
	EndIf
	If Not ProcessExists($pid) Then
		$pid = Run("srcds.exe " & IniRead("restart_config.ini", "Settings", "parameter", ""))
		TrayTip("", "Restarting!", 10)
		_log("Restarting!")
	EndIf

WEnd

Func _log($message)
	FileWrite("restart_log.log", @CRLF & "[" & @MDAY & "." & @MON & " " & @HOUR & ":" & @MIN & "] " & $message)
EndFunc   ;==>_log
Func _exit()
	If MsgBox(4, "Beenden", "Realy exit?") = 6 Then
		If MsgBox(4, "Exit", "Exit server?") = 6 Then ProcessClose($pid)
		Exit
	EndIf
EndFunc   ;==>_exit


Func udpcheck()
	$socket = UDPOpen(_GetIP(), IniRead("restart_config.ini", "Settings", "port", "27015"))
	UDPSend($socket, "0xFFFFFFFF54536F7572636520456E67696E6520517565727900")
	$timer = TimerInit()

	Do
		$recv = UDPRecv($socket, 2000)
	Until TimerDiff($timer) > 2000 Or $recv <> ""

	If $recv = "" Then
		ProcessClose($pid)
		$pid = Run("srcds.exe " & IniRead("restart_config.ini", "Settings", "parameter", ""))
		TrayTip("", "Server not answering to UDP request!", 10)
		_log("Error:   Server is no answering to UDP request   ...restarting")
	EndIf
	UDPCloseSocket($socket)
EndFunc   ;==>udpcheck


[/release]

Uhm… sourcecode ?

Source or no release.

It works. But it’s easier to just use a .bat watch guard IMO.

I don’t understand this. Couldn’t anyone just release something with some malicious stuff in it, and leave that out in the sourcecode?

I thought it was because everything should be opensource, not for security reasons. If anything this is just worse making you think it’s safe but it’s really not.

[editline]01:41AM[/editline]

Then again, I don’t think anyone did this.

Releasing the source allows us to compile it ourselves, if we don’t trust the author. And also, releasing the source makes the author more credible for future releases.

I would compile it myself, i would not thrust a '10’er with 10 posts, i would thrust him if he had like 1000 posts or something though

Well it’s written in AutoIt, so you might be able to decompile it.

decompiling is illegal …

i’ll release the source if you want to …

a .bat would not work if there is a messagebox or something

Snip i am stupid

get usedto it. the majority of the internet does not care.

and i was under the impression that a source code release is required for releases of this kind, although that might only apply to dll’s.

by the way. why not use serverchecker. thats what i usedto use.

it didnt worked on my root :confused: ( windows server 2008 )

or i was just to dump xP