-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path7dtdServerUpdateUtilityBeta.au3
10712 lines (10628 loc) · 608 KB
/
7dtdServerUpdateUtilityBeta.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Resources\phoenixtray.ico
#AutoIt3Wrapper_Outfile=Builds\7dtdServerUpdateUtility_v2.6.9.exe
#AutoIt3Wrapper_Compression=3
#AutoIt3Wrapper_Res_Comment=By Phoenix125 based on Dateranoth's ConanServerUtility v3.3.0-Beta.3
#AutoIt3Wrapper_Res_Description=7 Days To Die Dedicated Server Update Utility
#AutoIt3Wrapper_Res_Fileversion=2.6.9.0
#AutoIt3Wrapper_Res_ProductName=7dtdServerUpdateUtility
#AutoIt3Wrapper_Res_ProductVersion=2.6.9
#AutoIt3Wrapper_Res_CompanyName=http://www.Phoenix125.com
#AutoIt3Wrapper_Res_LegalCopyright=http://www.Phoenix125.com
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_Icon_Add=Resources\phoenixfaded.ico
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/mo
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
; *** Start added by AutoIt3Wrapper ***
#include <Array.au3>
#include <AutoItConstants.au3>
#include <ButtonConstants.au3>
#include <ColorConstants.au3>
#include <Date.au3>
#include <EditConstants.au3>
#include <EditConstants.au3>
#include <File.au3>
#include <GDIPlus.au3>
#include <GuiConstants.au3>
#include <GUIConstantsEx.au3>
#include <IE.au3>
#include <Inet.au3>
#include <ListViewConstants.au3>
#include <MsgBoxConstants.au3>
#include <Process.au3>
#include <StaticConstants.au3>
#include <String.au3>
#include <StringConstants.au3>
#include <TabConstants.au3>
#include <TrayConstants.au3>
#include <WinAPIProc.au3>
#include <WinAPISysWin.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("GUIResizeMode", $GUI_DOCKLEFT + $GUI_DOCKTOP)
; *** End added by AutoIt3Wrapper ***
$aUtilVerStable = "v2.6.9"
$aUtilVerBeta = "v2.6.9"
$aUtilVersion = $aUtilVerStable
Global $aUtilVerNumber = 18
; 1 = v2.3.3
; 2 = v2.3.4
; 3 = v2.5.0
; 4 = v2.5.1/2/3
; 5 = 2.5.4
; 6 = 2.5.5
; 7 = 2.5.6/7/8
; 8 = 2.5.9
; 9 = 2.6.0
;10 = 2.6.1
;11 = 2.6.2
;12 = 2.6.3
;13 = 2.6.4
;14 = 2.6.5
;15 = 2.6.6
;16 = 2.6.7
;17 = 2.6.8 2023-07-14
;18 = 2.6.9 2024-08-27
;**** Directives created by AutoIt3Wrapper_GUI ****
;Originally written by Dateranoth for use and modified for 7DTD by Phoenix125.com
;by https://gamercide.com on their server
;Distributed Under GNU GENERAL PUBLIC LICENSE
Global $aServerNameVer, $aGameName, $aSplash, $aRestartDaily, $aRestartDays, $aRestartHours, $aRestartMin, $aBeginDelayedShutdown, $aServerPID, $aQueryYN, $gWatchdogServerStartTimeCheck, $aExMemAmt, $aExMemRestart, $aTimeCheck1, $aServerName
Global Const $aUtilName = "7dtdServerUpdateUtility"
Global Const $aServerEXE = "7DaysToDieServer.exe"
Global Const $aServerShort = "7DTD"
Global $aGameName1 = "7 Days To Die"
Global Const $aIniFile = @ScriptDir & "\" & $aUtilName & ".ini"
Global $aUtilityVer = $aUtilName & " " & $aUtilVersion
Global $aUtilUpdateFile = @ScriptDir & "\__UTIL_UPDATE_AVAILABLE___.txt"
Global $aIniFailFile = @ScriptDir & "\___INI_FAIL_VARIABLES___.txt"
Global $aFolderLog = @ScriptDir & "\_Log\"
Global $aLogFile = $aFolderLog & $aUtilName & "_Log_" & @YEAR & "-" & @MON & "-" & @MDAY & ".txt"
Global $aLogDebugFile = $aFolderLog & $aUtilName & "_LogFull_" & @YEAR & "-" & @MON & "-" & @MDAY & ".txt"
Global $aFolderTemp = @ScriptDir & "\" & $aUtilName & "UtilFiles\"
DirCreate($aFolderTemp)
Global $aUtilCFGFile = $aFolderTemp & $aUtilName & "_cfg.ini"
Global $aDiscordSendWebhookEXE = $aFolderTemp & "DiscordSendWebhook.exe"
Global $aFilePlink = $aFolderTemp & "plink.exe"
Global $aServerBatchFile = @ScriptDir & "\_start_" & $aUtilName & ".bat"
Global $aCustomChatFile = @ScriptDir & "\" & $aUtilName & "_CustomChat.txt"
Global $aBatchDIR = @ScriptDir & "\BatchFiles"
Global $aSteamUpdateCMDValY = $aBatchDIR & "\Update_7DTD_Validate_YES.bat"
Global $aSteamUpdateCMDValN = $aBatchDIR & "\Update_7DTD_Validate_NO.bat"
Global $xPlayerName
Global $xPlayerID
DirCreate($aBatchDIR)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombieGroup.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombiehorde.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombie1.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombie2.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombie3.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombie6.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\zombiedog.jpg", $aFolderTemp, 0)
FileInstall("K:\AutoIT\_MyProgs\7dtdServerUpdateUtility\Resources\7DTDLogoPx.png", $aFolderTemp, 0)
; -----------------------------------------------------------------------------------------------------------------------
#Region ;**** Global Variables ****
If @Compiled = 0 Then
Global $aIconFile = @ScriptDir & "\7dtdServerUpdateUtility_Icons.exe"
Else
Global $aIconFile = @ScriptFullPath
EndIf
Global $aTelnetCheckInProgressTF = False
Global $aTimeCheck0 = _NowCalc()
Global $aTimeCheck1 = _NowCalc()
Global $aTimeCheck2 = _NowCalc()
Global $aTimeCheck3 = _NowCalc()
Global $aTimeCheck4 = _NowCalc()
Global $aTimeCheck8 = _NowCalc()
Global $aPlinkPID = -1
Global $aTelnetBuffer = ""
Global $aBeginDelayedShutdown = 0
Global $aFirstBoot = 1
Global $aRebootMe = "no"
Global $aUseSteamCMD = "yes"
Global $aOnlinePlayerLast = ""
Global $aRCONError = False
Global $aServerReadyTF = False
Global $aServerReadyOnce = True
Global $aNoExistingPID = True
Global $hGUI = 0
Global $aGUIW = 275
Global $aGUIH = 250
Global $tUserCtTF = False
Global $iEdit = 0
Global $tUserCnt = 1
Global $aBusy = False
Global $aSteamUpdateNow = False
Global $xCustomCommands[0]
Global $xCustomReponses[0]
Global $aCustomCommands = ""
;~ Global $aPlayerCountWindowTF = False
Global $tOnlinePlayerReady = False
Global $aPlayerCountShowTF = True
Global $aPlayersOnlineName = ""
Global $aPlayersOnlineSteamID = ""
Global $aPlayersJoinedTxt = ""
Global $aPlayersLeftTxt = ""
Global $aPlayersJoinedInGame = ""
Global $aPlayersJoinedDiscord = ""
Global $aPlayersLeftInGame = ""
Global $aPlayersLeftDiscord = ""
Global $aPlayersName = ""
Local $aFirstStartDiscordAnnounce = True
Local $xLabels[15] = ["Raw", "Name", "Map", "Folder", "Game", "ID", "Players", "Max Players", "Bots", "Server Type", "Environment", "Visibility", "VAC", "Version", "Extra Data Field"]
Global $aServerQueryName = "[Not Read Yet]"
Global $aPlayersCount = 0
Global $aPlayersMax = 0
Global $gWatchdogServerStartTimeCheck = _NowCalc()
Global $aIniExist = False
Global $aRemoteRestartUse = "no"
Global $aGameTime = "Day 1, 00:00"
Global $aNextHorde = 7
Global $tQueryLogReadDoneTF = False
Global $aServerNamFromLog = "[Not Read Yet]"
;~ Global $aServerNameToDisplay = ""
Global $tFailedCountQuery = 0
Global $tFailedCountTelnet = 0
Global $wGUIMainWindow = -1
Global $Config = -1
Global $wGUIMainWindow = -1
Global $hGUI_LoginLogo = -1
Global $W2_RestartServer = 9999999
Global $aRestartTime[1]
$aRestartTime[0] = 1
Global $aRestartMsg[1]
$aRestartMsg[0] = "Admin has requested a server reboot. Server is rebooting in 1 minute."
Global $aRestartCnt = 1
Global $sUseDiscordBotRestartServer = "no"
Global $sUseTwitchBotRestartServer = "no"
Global $aServerRebootReason = ""
Global $aRebootReason = ""
Global $aRebootConfigUpdate = "no"
Global $aAnnounceCount1 = 0
Global $aFPCount = 0
Global $aFPClock = _NowCalc()
Global $aServerName = "7 Days To Die"
Global $aSteamAppID = "294420"
Global $aUpdateSource = "0" ; 0 = SteamCMD , 1 = SteamDB.com
$aServerUpdateLinkVerStable = "http://www.phoenix125.com/share/7dtdlatestver.txt"
$aServerUpdateLinkVerBeta = "http://www.phoenix125.com/share/7dtdlatestbeta.txt"
$aServerUpdateLinkDLStable = "http://www.phoenix125.com/share/7dtdServerUpdateUtility.zip"
$aServerUpdateLinkDLBeta = "http://www.phoenix125.com/share/7dtdServerUpdateUtilityBeta.zip"
Global $aServerCrashMsgSentFailedTF = False
Global $aServerCrashMsgSentRestartTF = False
Global $aServerShuttingDownTF = False
Global $aShowUpdate = False
Global $aTelnetIP, $aTelnetPort, $aTelnetPass
#EndRegion ;**** Global Variables ****
Global Enum $WinHttpRequestOption_UserAgentString, _
$WinHttpRequestOption_URL, _
$WinHttpRequestOption_URLCodePage, _
$WinHttpRequestOption_EscapePercentInURL, _
$WinHttpRequestOption_SslErrorIgnoreFlags, _
$WinHttpRequestOption_SelectCertificate, _
$WinHttpRequestOption_EnableRedirects, _
$WinHttpRequestOption_UrlEscapeDisable, _
$WinHttpRequestOption_UrlEscapeDisableQuery, _
$WinHttpRequestOption_SecureProtocols, _
$WinHttpRequestOption_EnableTracing, _
$WinHttpRequestOption_RevertImpersonationOverSsl, _
$WinHttpRequestOption_EnableHttpsToHttpRedirects, _
$WinHttpRequestOption_EnablePassportAuthentication, _
$WinHttpRequestOption_MaxAutomaticRedirects, _
$WinHttpRequestOption_MaxResponseHeaderSize, _
$WinHttpRequestOption_MaxResponseDrainSize, _
$WinHttpRequestOption_EnableHttp1_1, _
$WinHttpRequestOption_EnableCertificateRevocationCheck
Global Const $WinHttpRequestOption_SslErrorIgnoreFlags_UnknownCA = 0x0100
Global Const $WinHttpRequestOption_SslErrorIgnoreFlags_CertWrongUsage = 0x0200
Global Const $WinHttpRequestOption_SslErrorIgnoreFlags_CertCNInvalid = 0x1000
Global Const $WinHttpRequestOption_SslErrorIgnoreFlags_CertDateInvalid = 0x2000
Global Const $WinHttpRequestOption_SslErrorIgnoreFlags_IgnoreAll = 0x3300 ;IGNORE ALL OF THE ABOVE
Global $oErrorFunc = ObjEvent("AutoIt.Error", "_ErrFunc")
Global $aObjErrFunc = "System"
Func _ErrFunc($oError = 0)
Local $tHex = "0x" & Hex($oError.number)
LogWrite(" [" & $aObjErrFunc & "] Error in ObjEvent [0x" & Hex($oError.number) & "] " & _ErrorCode($tHex))
EndFunc ;==>_ErrFunc
_ShowLoginLogo()
If FileExists($aFolderTemp) = 0 Then DirCreate($aFolderTemp)
If FileExists($aFolderLog) = 0 Then DirCreate($aFolderLog)
If FileExists($aIniFile) Then _FileWriteToLine($aIniFile, 3, "Version : " & $aUtilityVer, True)
Global $aCFGLastVerNumber = IniRead($aUtilCFGFile, "CFG", "LastVerNumber", $aUtilVerNumber)
IniWrite($aUtilCFGFile, "CFG", "LastVerNumber", $aUtilVerNumber)
Local $tUpdateINI = False
If $aCFGLastVerNumber < 1 Then
FileCopy(@ScriptDir & "\*.log*", $aFolderLog)
FileDelete(@ScriptDir & "\*.log*")
FileCopy(@ScriptDir & "\tt\*.*", $aFolderTemp & "tt\", $FC_OVERWRITE + $FC_CREATEPATH)
DirRemove(@ScriptDir & "\tt\", 1)
FileDelete(@ScriptDir & "\" & $aUtilName & "_lastpid.tmp")
FileDelete(@ScriptDir & "\7dtdServerUpdateUtility_PurgeLogFile.bat")
FileDelete(@ScriptDir & "\tt.zip")
$sDiscordPlayersMsg = "Players Online: **\o / \m** Game Time: **\t** Next Horde: **\n days**"
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Online Player Message (\o - Online Player Count, \m - Max Players, \t - Game Time, \n - Days to Next Horde) ###", $sDiscordPlayersMsg)
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 2 Then
Global $aSteamExtraCMD = IniRead($aIniFile, " --------------- GAME SERVER CONFIGURATION --------------- ", "SteamCMD extra commandline parameters (ex. -latest_experimental) ###", "public")
IniWrite($aIniFile, " --------------- GAME SERVER CONFIGURATION --------------- ", "SteamCMD extra commandline parameters (See note below) ###", $aSteamExtraCMD)
IniWrite($aIniFile, " --------------- KEEP ALIVE WATCHDOG --------------- ", "Number of failed responses (after server has responded at least once) before restarting server (1-10) (Default is 3) ###", "3")
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 3 Then
Local $sDiscordWebHookURLs = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "WebHook URL ###", "https://discordapp.com/api/webhooks/012345678901234567/abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcde")
Local $sDiscordWHPlayers = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "WebHook Online Player Count URL ###", "https://discordapp.com/api/webhooks/012345678901234567/abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcde")
Local $sDiscordBotName = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Bot Name ###", "7DTD Bot")
Local $bDiscordBotUseTTS = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Use TTS? (yes/no) ###", "no")
Local $sDiscordBotAvatar = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Bot Avatar Link ###", "")
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #1 Webhook URL ###", $sDiscordWebHookURLs)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #1 Bot Name (optional) ###", $sDiscordBotName)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #1 Avatar URL (optional) ###", $sDiscordBotAvatar)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #1 Use TTS (optional) (yes/no) ###", $bDiscordBotUseTTS)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #2 Webhook URL ###", $sDiscordWHPlayers)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #2 Bot Name (optional) ###", $sDiscordBotName)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #2 Avatar URL (optional) ###", $sDiscordBotAvatar)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #2 Use TTS (optional) (yes/no) ###", $bDiscordBotUseTTS)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #3 Webhook URL ###", $sDiscordWHPlayers)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #3 Bot Name (optional) ###", $sDiscordBotName)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #3 Avatar URL (optional) ###", $sDiscordBotAvatar)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #3 Use TTS (optional) (yes/no) ###", $bDiscordBotUseTTS)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #4 Webhook URL ###", "https://discordapp.com/api/webhooks/012345678901234567/abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcde")
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #4 Bot Name (optional) ###", $sDiscordBotName)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #4 Avatar URL (optional) ###", $sDiscordBotAvatar)
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #4 Use TTS (optional) (yes/no) ###", $bDiscordBotUseTTS)
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send RESTART/STATUS Msg (ie 1) ###", "1")
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send PLAYERS ONLINE Msg (ie 2) ###", "2")
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send CHAT Msg (ie 23) ###", "2")
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send PLAYERS DIE Msg (ie 1234) ###", "2")
Local $sUseDiscordBotDaily = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for DAILY reboot? (yes/no) ###", "yes")
Local $sUseDiscordBotUpdate = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for UPDATE reboot? (yes/no) ###", "yes")
Local $sUseDiscordBotRemoteRestart = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for REMOTE RESTART reboot? (yes/no) ###", "eys")
Local $sUseDiscordBotServersUpYN = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message when server is back online (yes/no) ###", "yes")
Local $sUseDiscordBotFirstAnnouncement = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for first ANNOUNCEMENT only? (reduces bot spam)(yes/no) ###", "no")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for DAILY reboot? (yes/no) ###", $sUseDiscordBotDaily)
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for UPDATE reboot? (yes/no) ###", $sUseDiscordBotUpdate)
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for REMOTE RESTART reboot? (yes/no) ###", $sUseDiscordBotRemoteRestart)
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message when server is back online (yes/no) ###", $sUseDiscordBotServersUpYN)
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for first ANNOUNCEMENT only? (reduces bot spam)(yes/no) ###", $sUseDiscordBotFirstAnnouncement)
Local $sDiscordDailyMessage = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Announcement DAILY (\m - minutes) ###", "Daily server restart begins in \m minute(s).")
Local $sDiscordUpdateMessage = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Announcement UPDATES (\m - minutes) ###", "Fun Pimps have released a new update. Server is rebooting in \m minute(s).")
Local $sDiscordRemoteRestartMessage = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Announcement REMOTE RESTART (\m - minutes) ###", "Admin has requested a server reboot. Server is rebooting in \m minute(s).")
Local $sDiscordServersUpMessage = IniRead($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Announcement when server is back online ###", "Server is online and ready for connection.")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement DAILY (\m - minutes) ###", $sDiscordDailyMessage)
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement UPDATES (\m - minutes) ###", $sDiscordUpdateMessage)
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement REMOTE RESTART (\m - minutes) ###", $sDiscordRemoteRestartMessage)
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement when server is back online ###", $sDiscordServersUpMessage)
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "__ Online Player message substitutions (\o Online Player Count, \m Max Players, \t Game Time, \h Days to Next Horde, \j Joined Sub-Msg, \l Left Sub-Msn, \a Online Players Sub-Msg) \n Next Line) __", "")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Message (see above for substitutions) ###", 'Players Online: **\o / \m** Game Time: **\t** Next Horde: **\h days**\j\l\a')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Join Player Sub-Message (\p - Player Name(s) of player(s) that joined server, \n Next Line) ###", 'Joined: *\p*')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Left Player Sub-Message (\p - Player Name(s) of player(s) that left server, \n Next Line) ###", 'Left: *\p*')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Sub-Message (\p - Player Name(s) of player(s) online, \n Next Line) ###", '\nOnline Players: **\p**')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Died Message (\p - Player Name, \n Next Line) ###", '*\p died.*')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Chat (\p - Player Name, \m Message) ###", '[Chat] **\p**: \m')
IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " MISC OPTIONS --------------- ", "Telnet: Stay Connected (Required for chat and death messaging) (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Use scheduled backups? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Backup days (comma separated 0-Everyday 1-Sunday 7-Saturday 0-7 ex.2,4,6) ###", "0")
$aBackupHours = "00,06,12,18"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Backup hours (comma separated 00-23 ex.04,16) ###", $aBackupHours)
$aBackupMin = "00"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Backup minute (00-59) ###", $aBackupMin)
$aBackupFull = "10"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Full " & $aGameName1 & " and Util folder backup every __ backups (0 to disable)(0-99) ###", $aBackupFull)
$aBackupAddedFolders = ""
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Additional backup folders / files (comma separated. Folders add \ at end. ex. C:\7DTD\,D:\7DTD Server\) ###", $aBackupAddedFolders)
$aBackupOutputFolder = @ScriptDir & "\Backups"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Output folder ###", $aBackupOutputFolder)
$aBackupNumberToKeep = "56"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Number of backups to keep (1-999) ###", $aBackupNumberToKeep)
$aBackupTimeoutSec = "600"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Max time in seconds to wait for backup to complete (30-999) ###", $aBackupTimeoutSec)
$aBackupCommandLine = "a -spf -r -tzip -ssw"
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "7zip backup additional command line parameters (Default: a -spf -r -tzip -ssw) ###", $aBackupCommandLine)
$aBackupInGame = "Server backup started."
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "In-Game announcement when backup initiated (Leave blank to disable) ###", $aBackupInGame)
$aBackupDiscord = "Server backup started."
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Discord announcement when backup initiated ###", $aBackupDiscord)
$aBackupTwitch = "Server backup started."
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Twitch announcement when backup initiated ###", $aBackupTwitch)
IniWrite($aIniFile, " --------------- GAME SERVER CONFIGURATION --------------- ", "SteamCMD Username (optional) ###", "")
IniWrite($aIniFile, " --------------- GAME SERVER CONFIGURATION --------------- ", "SteamCMD Password (optional) ###", "")
IniWrite($aIniFile, " --------------- GAME SERVER CONFIGURATION --------------- ", "SteamCMD commandline (caution: overwrites all settings above) ###", "")
IniWrite($aIniFile, " --------------- GAME SERVER CONFIGURATION --------------- ", "SteamCMD commandline (caution: overwrites all settings above) Write between lines below ###", "(Write between lines below)")
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Send Discord announcement when backup initiated (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- BACKUP --------------- ", "Send Twitch announcement when backup initiated (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for Online Player changes? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message when player dies? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for Player Chat? (yes/no) ###", "yes")
FileWriteLine($aIniFile, '<--- BEGIN SteamCMD CODE --->')
FileWriteLine($aIniFile, '')
FileWriteLine($aIniFile, '<--- END SteamCMD CODE --->')
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT BEFORE SteamCMD UPDATE AND SERVER START --------------- ", "1-Execute external script BEFORE update? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT BEFORE SteamCMD UPDATE AND SERVER START --------------- ", "1-Script to execute ###", "")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT BEFORE SteamCMD UPDATE AND SERVER START --------------- ", "1-Wait for script to complete? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT AFTER SteamCMD BUT BEFORE SERVER START --------------- ", "2-Execute external script AFTER update but BEFORE server start? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT AFTER SteamCMD BUT BEFORE SERVER START --------------- ", "2-Script to execute ###", "")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT AFTER SteamCMD BUT BEFORE SERVER START --------------- ", "2-Wait for script to complete? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN RESTARTING FOR SERVER *UPDATE* --------------- ", "3-Execute external script for server update restarts? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN RESTARTING FOR SERVER *UPDATE* --------------- ", "3-Script to execute ###", "")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN RESTARTING FOR SERVER *UPDATE* --------------- ", "3-Wait for script to complete? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN RESTARTING FOR *DAILY* SERVER RESTART --------------- ", "4-Execute external script for daily server restarts? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN RESTARTING FOR *DAILY* SERVER RESTART --------------- ", "4-Script to execute ###", "")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN RESTARTING FOR *DAILY* SERVER RESTART --------------- ", "4-Wait for script to complete? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN FIRST RESTART ANNOUNCEMENT IS MADE --------------- ", "5-Execute external script when first restart announcement is made? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN FIRST RESTART ANNOUNCEMENT IS MADE --------------- ", "5-Script to execute ###", "")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT WHEN FIRST RESTART ANNOUNCEMENT IS MADE --------------- ", "5-Wait for script to complete? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT DURING RESTART WHEN REMOTE RESTART REQUEST IS MADE --------------- ", "6-Execute external script during restart when a remote restart request is made? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT DURING RESTART WHEN REMOTE RESTART REQUEST IS MADE --------------- ", "6-Script to execute ###", "")
IniWrite($aIniFile, " --------------- EXECUTE EXTERNAL SCRIPT DURING RESTART WHEN REMOTE RESTART REQUEST IS MADE --------------- ", "6-Wait for script to complete? (yes/no) ###", "no")
IniWrite($aIniFile, " --------------- (ALMOST) FUTURE PROOF UPDATE OPTIONS --------------- ", "Rename the Mod Folder (therefore saving and disabling it) if Future Proof was needed (3 consecutive failed starts after an update)? (yes/no) ###", "yes")
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 4 Then
IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " MISC OPTIONS --------------- ", "Telnet: Monitor all traffic (Required for player chat and death announcements) (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- " & StringUpper($aUtilName) & " MISC OPTIONS --------------- ", "Telnet: Check traffic every _ seconds) (1-10) ###", 5)
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 5 Then
Global $aServerDiscordWHSelChat = IniRead($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send CHAT Msg (ie 23) ###", "")
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send GLOBAL CHAT Msg (ie 23) ###", $aServerDiscordWHSelChat)
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send ALL CHAT Msg (ie 23) ###", "")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message for Player All Chat? (yes/no) ###", "no")
Global $sDiscordPlayerChatMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Chat (\p - Player Name, \m Message) ###", "'[\t] **\p**: \m'")
$sDiscordPlayerChatMsg = StringReplace($sDiscordPlayerChatMsg, "[Chat]", "[\t]")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Chat (\p - Player Name, \m Message, \t Msg type (ex. Global,Friend)", $sDiscordPlayerChatMsg)
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 6 Then
Local $tTxt = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Message (see above for substitutions) ###", 'Players Online: **\o / \m** Game Time: **\t** Next Horde: **\h days**\j\l\a')
$tTxt = StringReplace($tTxt, 'days**\j\l\a', 'days** \j\l\a')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Message (see above for substitutions) ###", $tTxt)
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 7 Then
Global $sDiscordPlayersMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Message (see above for substitutions) ###", _
'Players Online: **\o / \m** Game Time: **\t** Next Horde: **\h days**\n\j\l :hammer_pick: \a')
Global $sDiscordPlayerJoinMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Join Player Sub-Message (\p - Player Name(s) of player(s) that joined server, \n Next Line) ###", ':white_check_mark: Joined: ***\p***')
Global $sDiscordPlayerLeftMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Left Player Sub-Message (\p - Player Name(s) of player(s) that left server, \n Next Line) ###", ':x: Left: ***\p***')
Global $sDiscordPlayerOnlineMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Sub-Message (\p - Player Name(s) of player(s) online, \n Next Line) ###", '\nOnline Players: **\p**')
Global $sDiscordPlayerDiedMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Died Message (\p - Player Name, \n Next Line) ###", '*:pirate_flag: \p died.*')
Global $sDiscordPlayerChatMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Chat (\p - Player Name, \m Message, \t Msg type (ex. Global,Friend)", '[\t] **\p**: \m')
If $sDiscordPlayersMsg = 'Players Online: **\o / \m** Game Time: **\t** Next Horde: **\h days** \j\l\a' Then
$sDiscordPlayersMsg = 'Players Online: **\o / \m** Game Time: **\t** Next Horde: **\h days**\n\j\l :hammer_pick: \a'
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Message (see above for substitutions) ###", $sDiscordPlayersMsg)
EndIf
If $sDiscordPlayerJoinMsg = 'Joined: *\p*' Then
$sDiscordPlayerJoinMsg = ':white_check_mark: Joined: ***\p***'
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Join Player Sub-Message (\p - Player Name(s) of player(s) that joined server, \n Next Line) ###", $sDiscordPlayerJoinMsg)
EndIf
If $sDiscordPlayerLeftMsg = 'Left: *\p*' Then
$sDiscordPlayerLeftMsg = ':x: Left: ***\p***'
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Left Player Sub-Message (\p - Player Name(s) of player(s) that left server, \n Next Line) ###", $sDiscordPlayerLeftMsg)
EndIf
If $sDiscordPlayerOnlineMsg = '\nOnline Players: **\p**' Then
$sDiscordPlayerOnlineMsg = '\nOnline Players: **\p**'
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Online Player Sub-Message (\p - Player Name(s) of player(s) online, \n Next Line) ###", $sDiscordPlayerOnlineMsg)
EndIf
If $sDiscordPlayerDiedMsg = '*\p died.*' Then
$sDiscordPlayerDiedMsg = '*:pirate_flag: \p died.*'
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Player Died Message (\p - Player Name, \n Next Line) ###", $sDiscordPlayerDiedMsg)
EndIf
Global $aServerDiscord1Avatar = IniRead($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #1 Avatar URL (optional) ###", "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg")
Global $aServerDiscord2Avatar = IniRead($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #2 Avatar URL (optional) ###", "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg")
Global $aServerDiscord3Avatar = IniRead($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #3 Avatar URL (optional) ###", "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg")
Global $aServerDiscord4Avatar = IniRead($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #4 Avatar URL (optional) ###", "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg")
If $aServerDiscord1Avatar = "" Then
$aServerDiscord1Avatar = "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg"
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #1 Avatar URL (optional) ###", $aServerDiscord1Avatar)
EndIf
If $aServerDiscord2Avatar = "" Then
$aServerDiscord2Avatar = "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg"
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #2 Avatar URL (optional) ###", $aServerDiscord2Avatar)
EndIf
If $aServerDiscord3Avatar = "" Then
$aServerDiscord3Avatar = "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg"
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #3 Avatar URL (optional) ###", $aServerDiscord3Avatar)
EndIf
If $aServerDiscord4Avatar = "" Then
$aServerDiscord4Avatar = "http://www.phoenix125.com/share/Discord/DiscordAvatar7DTD.jpg"
IniWrite($aIniFile, " --------------- DISCORD WEBHOOK --------------- ", "Discord #4 Avatar URL (optional) ###", $aServerDiscord4Avatar)
EndIf
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 8 Then
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message every blood moon? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message every new day at midnight? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Blood Moon time (hour) to send Discord Msg (00-23) ###", "7")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement every blood moon (Uses online players substitutes. \p All Online Players)", 'Game Time: **\t** :full_moon: __**HORDE DAY!**__ :man_zombie:')
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement every new day (Uses online players substitutes. \p All Online Players)", 'Game Time: **\t** Next Horde: **\h days**')
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 9 Then
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message when blood moon done? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement when blood moon done (Uses online players substitutes. \p All Online Players)", 'Game Time: **\t** :new_moon: **Horde Day Finished**')
IniWrite($aIniFile, " --------------- DISCORD MESSAGE WEBHOOK SELECT --------------- ", "Webhook number(s) to send New Day and Horde Msg (ie 14) ###", "3")
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 10 Then
IniWrite($aIniFile, " --------------- KEEP ALIVE WATCHDOG ---------------", "Disable watchdog. Util will NOT start server (but can shut it down)? (yes/no) ###", "no")
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 11 Then
Global $sInGameDailyRestartMessage = IniRead($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement DAILY (\m - minutes) ###", "[FF8C00]Daily server restart begins in \m minute(s).")
$sInGameDailyRestartMessage = "[FF8C00]" & $sInGameDailyRestartMessage
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement DAILY RESTART (\m - minutes) ###", $sInGameDailyRestartMessage)
Global $sInGameAnnounceRestartsDailyYN = "yes"
Global $sInGameAnnounceRestartsUpdateYN = "yes"
Global $sInGameAnnounceRestartsRemoteYN = "yes"
Global $sInGameAnnounceDailyYN = "yes"
Global $sInGameAnnounceDailyHour = 7
Global $sInGameAnnouncePlayerJoinYN = "yes"
Global $sInGameAnnounceBackupYN = "yes"
Global $sInGameDailyMessage = "[FF8C00]Next Horde: \h days Players: \o"
Global $sInGamePlayerJoinMessage = "[FF8C00]Welcome \y! Next Horde: \h days Players: \o"
Global $sAnnounceBloodMoonOffset = 0
IniWrite($aIniFile, " --------------- ANNOUNCEMENT CONFIGURATION --------------- ", "Blood Moon Day Announcement Offset +(0-99) days (Use when horde day msg gets off sync) ###", $sAnnounceBloodMoonOffset)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce DAILY RESTARTS messages in-game? (Requires telnet) (yes/no) ###", $sInGameAnnounceRestartsDailyYN)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce UPDATES messages in-game? (Requires telnet) (yes/no) ###", $sInGameAnnounceRestartsUpdateYN)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce REMOTE RESTARTS messages in-game? (Requires telnet) (yes/no) ###", $sInGameAnnounceRestartsRemoteYN)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce DAILY messages in-game? (Requires telnet) (yes/no) ###", $sInGameAnnounceDailyYN)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce DAILY messages in-game Hour to Send? (Requires telnet) (0-23) ###", $sInGameAnnounceDailyHour)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce PLAYER JOIN messages in-game? (Requires telnet) (yes/no) ###", $sInGameAnnouncePlayerJoinYN)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announce BACKUP STARTED messages in-game? (Requires telnet) (yes/no) ###", $sInGameAnnounceBackupYN)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement DAILY (\m - minutes) ###", $sInGameDailyMessage)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement PLAYER JOIN (\o Player Count, \m Max Players, \t Game Time, \h Days to Next Horde, \n Next Line, \p Online Player Names, \y Player Joined Name, \q Player Left Name) ###", $sInGamePlayerJoinMessage)
Global $sDiscordPlayerJoinMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Join Player Sub-Message (\p - Player Name(s) of player(s) that joined server, \n Next Line) ###", ':white_check_mark: Joined: ***\y***')
Global $sDiscordPlayerLeftMsg = IniRead($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Left Player Sub-Message (\p - Player Name(s) of player(s) that left server, \n Next Line) ###", ':x: Left: ***\q***')
Global $sInGameUpdateMessage = IniRead($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement UPDATES (\m - minutes) ###", "[FF8C00]Fun Pimps have released a new update. Server is rebooting in \m minute(s).")
Global $sInGameRemoteRestartMessage = IniRead($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement REMOTE RESTART (\m - minutes) ###", "[FF8C00]Admin has requested a server reboot. Server is rebooting in \m minute(s).")
$sDiscordPlayerJoinMsg = StringReplace($sDiscordPlayerJoinMsg, "\p", "\y")
$sDiscordPlayerLeftMsg = StringReplace($sDiscordPlayerLeftMsg, "\p", "\q")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Join Player Sub-Message (\y - Player Name(s) of player(s) that joined server, \n Next Line) ###", $sDiscordPlayerJoinMsg)
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Left Player Sub-Message (\q - Player Name(s) of player(s) that left server, \n Next Line) ###", $sDiscordPlayerLeftMsg)
$sInGameUpdateMessage = "[FF8C00]" & $sInGameUpdateMessage
$sInGameRemoteRestartMessage = "[FF8C00]" & $sInGameRemoteRestartMessage
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement UPDATES (\m - minutes) ###", $sInGameUpdateMessage)
IniWrite($aIniFile, " --------------- IN-GAME ANNOUNCEMENT CONFIGURATION --------------- ", "Announcement REMOTE RESTART (\m - minutes) ###", $sInGameRemoteRestartMessage)
Global $aSendTelnetMaxAttempts = 3
IniWrite($aIniFile, " --------------- ADVANCED HIDDEN OPTIONS --------------- ", "Send Telnet Command: Number of attempts (1-5) ###", $aSendTelnetMaxAttempts)
Global $aRestartServerNowPause = 10
IniWrite($aIniFile, " --------------- ADVANCED HIDDEN OPTIONS --------------- ", "Restart Now pause (Delay between Restart Now message being sent and Server Reboot) (0-60) seconds ###", $aRestartServerNowPause)
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 13 Then
IniWrite($aIniFile, " --------------- ADVANCED HIDDEN OPTIONS --------------- ", "CPU Affinity in Hex (Adds /AFFNITY x to commandline. Ex 0000001 for CPU 0, 000005 For CPU 1&3) ###", "")
$tUpdateINI = True
EndIf
If $aCFGLastVerNumber < 16 Then
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement when server crash is first detected by Watchdog ###", ":warning: Server crash detected. Server will restart if no response in one minute.")
IniWrite($aIniFile, " --------------- DISCORD MESSAGES --------------- ", "Announcement when server crash is forcing a server roboot by Watchdog ###", ":exclamation::exclamation: Server crash detected. RESTARTING SERVER :exclamation::exclamation:")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message when Watchdog first detects server crash? (yes/no) ###", "yes")
IniWrite($aIniFile, " --------------- DISCORD INTEGRATION --------------- ", "Send Discord message when Watchdog detects server crash and will restart server? (yes/no) ###", "yes")
$tUpdateINI = True
EndIf
If $tUpdateINI Then
ReadUini($aIniFile, $aLogFile)
FileDelete($aIniFile)
UpdateIni($aIniFile)
EndIf
; -----------------------------------------------------------------------------------------------------------------------
#Region ;**** Startup Checks. Initial Log, Read INI, Check for Correct Paths, Check Remote Restart is bound to port. ****
OnAutoItExitRegister("Gamercide")
Global $aSplash = _Splash("7dtdServerUpdateUtility started.")
LogWrite(" ============================ " & $aUtilityVer & " Started ============================")
FileDelete($aUtilUpdateFile)
If FileExists($aIniFile) Then _FileWriteToLine($aIniFile, 3, "Version : " & $aUtilityVer, True)
Global $aServerPID = PIDReadServer($aSplash)
Global $gWatchdogServerStartTimeCheck = IniRead($aUtilCFGFile, "CFG", "Last Server Start", "no")
If $gWatchdogServerStartTimeCheck = "no" Then
$gWatchdogServerStartTimeCheck = _NowCalc()
IniWrite($aUtilCFGFile, "CFG", "Last Server Start", $gWatchdogServerStartTimeCheck)
EndIf
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Importing settings from " & $aIniFile & ".")
Global $aShowConfigSplash = True
ReadUini($aIniFile, $aLogFile)
Global $aShowConfigSplash = False
If FileExists($aBackupOutputFolder) = 0 Then DirCreate($aBackupOutputFolder)
If FileExists($aCustomChatFile) = 0 Then _CustomCommandsWriteDefault($aCustomChatFile)
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Importing custom chat commands from " & _FileNameFromPath($aCustomChatFile) & ".")
_CustomCommandsRead($aCustomChatFile)
If $aTelnetIP = "" Then
$aTelnetIP = $aServerIP
EndIf
If $aUtilBetaYN = "1" Then
$aServerUpdateLinkVerUse = $aServerUpdateLinkVerBeta
$aServerUpdateLinkDLUse = $aServerUpdateLinkDLBeta
$aUtilVersion = $aUtilVerBeta
Else
$aServerUpdateLinkVerUse = $aServerUpdateLinkVerStable
$aServerUpdateLinkDLUse = $aServerUpdateLinkDLStable
$aUtilVersion = $aUtilVerStable
EndIf
$aUtilityVer = $aUtilName & " " & $aUtilVersion
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Updating config file.")
;~ AppendConfigSettings()
;GetfromServerConfig()
If $aUpdateUtil = "yes" Then
UtilUpdate($aServerUpdateLinkVerUse, $aServerUpdateLinkDLUse, $aUtilVersion, $aUtilName)
EndIf
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Creating temp config file.")
Global $sConfigPath = $aServerDirLocal & "\" & $aConfigFile
Local $sFileExists = FileExists($sConfigPath)
If $sFileExists = 0 Then
LogWrite("!!! ERROR !!! Could not find " & $sConfigPath)
SplashOff()
$tMsg = MsgBox($MB_YESNO, $aConfigFile & " Not Found", "Could not find 7DTD Config: [" & _FileNameFromPath($sConfigPath) & "]" & @CRLF & @CRLF & $sConfigPath & @CRLF & @CRLF & _
"This is normal for New Install" & @CRLF & "Do you wish to continue with installation?" & @CRLF & "(YES) Continue with installation" & @CRLF & "(NO) Open Config Window", 60)
If $tMsg = 7 Then
LogWrite("!!! ERROR !!! Could not find " & $sConfigPath & ". Config Window opened.")
GUI_Config()
Else
EndIf
EndIf
Global $aServerTelnetReboot = "no"
_ImportServerConfig()
#EndRegion ;**** Startup Checks. Initial Log, Read INI, Check for Correct Paths, Check Remote Restart is bound to port. ****
If $aUseSteamCMD = "yes" Then
Local $sFileExists = FileExists($aSteamCMDDir & "\steamcmd.exe")
If $sFileExists = 0 Then
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Downloading and installing SteamCMD.")
InetGet("https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip", @ScriptDir & "\steamcmd.zip", 0)
DirCreate($aSteamCMDDir) ; to extract to
_ExtractZip(@ScriptDir & "\steamcmd.zip", "", "steamcmd.exe", $aSteamCMDDir)
FileDelete(@ScriptDir & "\steamcmd.zip")
LogWrite(" [Steam Update] Running SteamCMD. [steamcmd.exe +quit]")
RunWait("" & $aSteamCMDDir & "\steamcmd.exe +quit", @SW_MINIMIZE)
If Not FileExists($aSteamCMDDir & "\steamcmd.exe") Then
MsgBox(0x0, "SteamCMD Not Found", "Could not find steamcmd.exe at " & $aSteamCMDDir, 60)
;~ _ExitUtil()
EndIf
EndIf
Else
Local $cFileExists = FileExists($aServerDirLocal & "\" & $aServerEXE)
If $cFileExists = 0 Then
MsgBox(0x0, "7 Days To Die Server Not Found", "Could not find " & $aServerEXE & " at " & $aServerDirLocal, 60)
;~ _ExitUtil()
EndIf
EndIf
_SteamCMDCommandlineRead()
If $aSteamUpdateCommandline = "" Then
_SteamCMDCreate()
_SteamCMDCommandlineWrite()
EndIf
_SteamCMDBatchFilesCreate()
#Region ;**** Check for Update At Startup ****
If ($aCheckForUpdate = "yes") Then
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Checking for server updates.")
LogWrite(" [Update] Running initial update check . . ")
Local $bRestart = UpdateCheck(True, $aSplash, True)
If $bRestart Then
If ProcessExists($aServerPID) Then
$aBeginDelayedShutdown = 1
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Server outdated. Server update scheduled.")
Sleep(5000)
Else
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Server outdated. Server update process inititiated.")
SteamUpdate()
EndIf
EndIf
EndIf
#EndRegion ;**** Check for Update At Startup ****
ExternalScriptExist()
_StartRemoteRestart()
#Region ;**** Create Tray ****
ControlSetText($aSplash, "", "Static1", $aUtilName & " " & $aUtilVersion & " started." & @CRLF & @CRLF & "Preparing icon tray.")
Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
Opt("TrayOnEventMode", 1)
Global $iTrayQueryServerName = TrayCreateItem("PID(" & $aServerPID & ") " & $aServerQueryName)
TrayItemSetOnEvent(-1, "TrayShowPlayerCount")
Global $iTrayQueryPlayers = TrayCreateItem("Players Online: [Enable Query or Online Player Check]")
TrayItemSetOnEvent(-1, "TrayShowPlayerCount")
TrayCreateItem("") ; Create a separator line.
Local $iTrayExitCloseN = TrayCreateItem("Util CONFIG")
TrayItemSetOnEvent(-1, "TrayUtilConfig")
Local $iTrayExitCloseN = TrayCreateItem("Util LOG")
TrayItemSetOnEvent(-1, "TrayUtilLog")
Local $iTrayAbout = TrayCreateItem("About")
TrayItemSetOnEvent(-1, "TrayAbout")
Local $iTrayAbout = TrayCreateItem("Restart Util")
TrayItemSetOnEvent(-1, "TrayRestartUtil")
Local $iTrayUpdateUtilCheck = TrayCreateItem("Check for Util Update")
TrayItemSetOnEvent(-1, "TrayUpdateUtilCheck")
Local $iTrayUpdateUtilPause = TrayCreateItem("Pause Util")
TrayItemSetOnEvent(-1, "TrayUpdateUtilPause")
TrayCreateItem("") ; Create a separator line.
Local $iTrayBackupFocused = TrayCreateItem("Backup: Focused (Save & Config Files)")
TrayItemSetOnEvent(-1, "TrayBackupFocused")
Local $iTrayBackupFocused = TrayCreateItem("Backup: Full (Entire Server & Config)")
TrayItemSetOnEvent(-1, "TrayBackupFull")
TrayCreateItem("") ; Create a separator line.
Local $iTraySendMessage = TrayCreateItem("Send global chat message")
TrayItemSetOnEvent(-1, "TraySendMessage")
Local $iTraySendInGame = TrayCreateItem("Send telnet command")
TrayItemSetOnEvent(-1, "TraySendInGame")
TrayCreateItem("") ; Create a separator line.
Local $iTrayPlayerCount = TrayCreateItem("Show Online Players Window")
TrayItemSetOnEvent(-1, "TrayShowPlayerCount")
Local $iTrayPlayerCheckPause = TrayCreateItem("Disable Online Players Check/Log")
TrayItemSetOnEvent(-1, "TrayShowPlayerCheckPause")
Local $iTrayPlayerCheckUnPause = TrayCreateItem("Enable Online Players Check/Log")
TrayItemSetOnEvent(-1, "TrayShowPlayerCheckUnPause")
TrayCreateItem("") ; Create a separator line.
Local $iTrayUpdateServCheck = TrayCreateItem("Check for Server Update")
TrayItemSetOnEvent(-1, "TrayUpdateServCheck")
Local $iTrayUpdateServPause = TrayCreateItem("Disable Server Update Check")
TrayItemSetOnEvent(-1, "TrayUpdateServPause")
Local $iTrayUpdateServUnPause = TrayCreateItem("Enable Server Update Check")
TrayItemSetOnEvent(-1, "TrayUpdateServUnPause")
TrayCreateItem("") ; Create a separator line.
Local $iTrayRemoteRestart = TrayCreateItem("Initiate Remote Restart")
TrayItemSetOnEvent(-1, "TrayRemoteRestart")
Local $iTrayRestartNow = TrayCreateItem("Restart Server (with Options Window)")
TrayItemSetOnEvent(-1, "TrayRestartNow")
TrayCreateItem("") ; Create a separator line.
Local $iTrayExitCloseN = TrayCreateItem("Server CONFIG")
TrayItemSetOnEvent(-1, "TrayServerConfig")
Local $iTrayExitCloseN = TrayCreateItem("Server LOG")
TrayItemSetOnEvent(-1, "TrayServerLog")
TrayCreateItem("") ; Create a separator line.
Local $iTrayExitCloseN = TrayCreateItem("Exit: Do NOT Shut Down Servers")
TrayItemSetOnEvent(-1, "TrayExitCloseN")
Local $iTrayExitCloseY = TrayCreateItem("Exit: Shut Down Servers")
TrayItemSetOnEvent(-1, "TrayExitCloseY")
If $aCheckForUpdate = "yes" Then
TrayItemSetState($iTrayUpdateServPause, $TRAY_ENABLE)
TrayItemSetState($iTrayUpdateServUnPause, $TRAY_DISABLE)
Else
TrayItemSetState($iTrayUpdateServPause, $TRAY_DISABLE)
TrayItemSetState($iTrayUpdateServUnPause, $TRAY_ENABLE)
EndIf
If $aServerOnlinePlayerYN = "yes" Then
TrayItemSetState($iTrayPlayerCheckPause, $TRAY_ENABLE)
TrayItemSetState($iTrayPlayerCheckUnPause, $TRAY_DISABLE)
Else
TrayItemSetState($iTrayPlayerCheckPause, $TRAY_DISABLE)
TrayItemSetState($iTrayPlayerCheckUnPause, $TRAY_ENABLE)
EndIf
TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu.
Func TrayAbout()
MsgBox($MB_SYSTEMMODAL, $aUtilName, $aUtilName & @CRLF & "Version: " & $aUtilVersion & @CRLF & @CRLF & "Install Path: " & @ScriptDir & @CRLF & @CRLF & "Discord: http://discord.gg/EU7pzPs" & @CRLF & "Website: http://www.phoenix125.com", 15)
EndFunc ;==>TrayAbout
Func TrayRestartUtil()
_RestartUtil()
EndFunc ;==>TrayRestartUtil
If WinExists($hGUI_LoginLogo) Then GUIDelete($hGUI_LoginLogo)
ShowOnlineGUI(True)
_UpdateTray()
#EndRegion ;**** Create Tray ****
If $aUpdateUtil = "yes" Then AdlibRegister("RunUtilUpdate", 28800000)
Global $gTelnetTimeCheck0 = _NowCalc()
Global $gQueryTimeCheck0 = _DateAdd('h', -2, _NowCalc())
Global $gServerUpdatedTimeCheck0 = IniRead($aUtilCFGFile, "CFG", "Last Server Update", "no")
If $gServerUpdatedTimeCheck0 = "no" Then
$gServerUpdatedTimeCheck0 = _NowCalc()
IniWrite($aUtilCFGFile, "CFG", "Last Server Update", $gServerUpdatedTimeCheck0)
EndIf
; -----------------------------------------------------------------------------------------------------------------------
$aServerCheck = TimerInit()
If ProcessExists($aServerPID) Then
_PlinkSend("version")
Sleep(500)
_OnlinePlayerCheck()
$aServerCheck = _DateAdd('h', -1, $aServerCheck)
Else
$aServerCheck = _DateAdd('h', -1, $aServerCheck)
ControlSetText($aSplash, "", "Static1", "Preparing to start server...")
EndIf
If $aTelnetMonitorAllYN = "yes" Then AdlibRegister("_TelnetCheck", $aTelnetTrafficCheckSec * 1000)
While True ;**** Loop Until Closed ****
If TimerDiff($aServerCheck) > 10000 Then
TraySetToolTip("Server process check in progress...")
TraySetIcon(@ScriptName, 201)
#Region ;**** Listen for Remote Restart Request ****
If $aRemoteRestartUse = "yes" Then
Local $sRestart = _RemoteRestart($MainSocket, $aRemoteRestartCode, $aRemoteRestartKey, $sObfuscatePass, $aServerIP, $aServerName)
Switch @error
Case 0
If ProcessExists($aServerPID) And ($aBeginDelayedShutdown = 0) Then
Local $MEM = ProcessGetStats($aServerPID, 0)
If @error Then
Else
LogWrite(" [" & $aServerName & " (PID: " & $aServerPID & ")] [Work Memory:" & $MEM[0] & " | Peak Memory:" & $MEM[1] & "] " & $sRestart)
EndIf
If ($sUseDiscordBotDaily = "yes") Or ($sUseDiscordBotUpdate = "yes") Or ($sUseTwitchBotDaily = "yes") Or ($sUseTwitchBotUpdate = "yes") Or ($sInGameAnnounceRestartsRemoteYN = "yes") Then
; Local $aMaintenanceMsg = """WARNING! " & $sAnnounceRemoteRestartMessage & " Restarting server in " & $aDelayShutdownTime & " minutes...""" & @CRLF
$aBeginDelayedShutdown = 1
$aRebootReason = "remoterestart"
$aTimeCheck0 = _NowCalc
Else
RunExternalRemoteRestart()
CloseServer($aTelnetIP, $aTelnetPort, $aTelnetPass)
EndIf
EndIf
Case 1 To 4
LogWrite(" " & $sRestart & @CRLF)
EndSwitch
EndIf
#EndRegion ;**** Listen for Remote Restart Request ****
#Region ;**** Watchdog and Server Start, Rename, Update, etc. ****
If $aDisableWatchdog = "no" And Not ProcessExists($aServerPID) Then
$tReturn = _CheckForExistingServer()
If $tReturn = 0 Then
$aBeginDelayedShutdown = 0
$aSplash = _Splash("Starting server.")
If $aExecuteExternalScript = "yes" Then
LogWrite(" Executing External Script " & $aExternalScriptDir & "\" & $aExternalScriptName)
If $aExternalScriptAnnounceWait = "no" Then
If $aExternalScriptHideYN = "yes" Then
Run($aExternalScriptFile, @SW_HIDE)
Else
Run($aExternalScriptFile)
EndIf
Else
If $aExternalScriptHideYN = "yes" Then
RunWait($aExternalScriptFile, @SW_HIDE)
Else
RunWait($aExternalScriptFile)
EndIf
EndIf
EndIf
$LogTimeStamp = $aServerDirLocal & '\7DaysToDieServer_Data\output_log_dedi' & StringRegExpReplace(_NowCalc(), "[\\\/\: ]", "_") & ".txt"
IniWrite($aUtilCFGFile, "CFG", "Last Log Time Stamp", $LogTimeStamp)
If $aServerAffinity <> "" Then $aServerAffinity = "/AFFINITY " & $aServerAffinity & " "
Local $tRun = @ComSpec & " /c " & 'start "7DaysToDieServer" ' & $aServerAffinity & '"' & $aServerDirLocal & "\" & $aServerEXE & '" -logfile "' & $LogTimeStamp & '" -quit -batchmode -nographics ' & $aServerExtraCMD & " -configfile=" & $aConfigFileTemp & " -dedicated"
$aServerShuttingDownTF = False
PurgeLogFile()
_ImportServerConfig()
Run($tRun, $aServerDirLocal, @SW_HIDE)
LogWrite(" [Server] ******** Server Started ********", " [Server] ******** Server Started ******** [" & $tRun & "]")
For $x = 1 To 10
Sleep(500)
$aServerPID = _CheckForExistingServer(True) ; True = New server... used to clarify log entry
If $aServerPID > 0 Then ExitLoop
Next
$aServerCrashMsgSentFailedTF = False
$gWatchdogServerStartTimeCheck = _NowCalc()
IniWrite($aUtilCFGFile, "CFG", "Last Server Start", $gWatchdogServerStartTimeCheck)
ControlSetText($aSplash, "", "Static1", "Server Started." & @CRLF & @CRLF & "PID[" & $aServerPID & "]")
$gTelnetTimeCheck0 = _NowCalc()
$tQueryLogReadDoneTF = False
$aFPCount = $aFPCount + 1
If ($aFPCount = 3) And ($aFPAutoUpdateYN = "yes") Then FPRun()
; **** Retrieve Server Version ****
Sleep(3000)
ControlSetText($aSplash, "", "Static1", "Server Started." & @CRLF & @CRLF & "Retrieving server version from log.")
Local $sLogPath = $LogTimeStamp
Local $sLogPathOpen = FileOpen($sLogPath, 0)
Local $sLogRead = StringLeft(FileRead($sLogPathOpen), 10000)
$aGameVer = _ArrayToString(_StringBetween($sLogRead, "INF Version: ", " Compatibility Version"))
FileClose($sLogPath)
If $aGameVer = "-1" Then
Sleep(2000)
Local $sLogPath = $LogTimeStamp
Local $sLogPathOpen = FileOpen($sLogPath, 0)
Local $sLogRead = StringLeft(FileRead($sLogPathOpen), 10000)
$xGameVer = _StringBetween($sLogRead, "INF Version: ", " Compatibility Version")
If @error Then
ControlSetText($aSplash, "", "Static1", "Server Started." & @CRLF & @CRLF & "Unable to retrieve server version from log.")
Sleep(5000)
$aGameVer = "[Unable to retrieve]"
Else
$aGameVer = $xGameVer[0]
EndIf
$aGameVer = _ArrayToString(_StringBetween($sLogRead, "INF Version: ", " Compatibility Version"))
FileClose($sLogPath)
EndIf
ControlSetText($aSplash, "", "Static1", "Server Started." & @CRLF & @CRLF & "Server Version: " & $aGameVer)
LogWrite(" [Server] Server version: " & $aGameVer & ".", " [Server] Server version: " & $aGameVer & ". Version derived from """ & $LogTimeStamp & """.")
IniWrite($aUtilCFGFile, "CFG", "Last Server Version", $aGameVer)
Sleep(3000)
; **** Append Server Version to Server Name And/Or Change GameName to Server Version ****
Local $tRebootTF = False
If $aAppendVerBegin = "yes" Or $aAppendVerEnd = "yes" Then
ControlSetText($aSplash, "", "Static1", "Server Started." & @CRLF & @CRLF & "Waiting for Server Name to be written in log")
$aServerNamFromLog = _GetServerNameFromLog($aSplash)
Local $tConfigPathOpen = FileOpen($aConfigFileTempFull, 0)
Local $tConfigRead2 = FileRead($tConfigPathOpen)
FileClose($tConfigPathOpen)
Local $tConfigRead1 = StringRegExpReplace($tConfigRead2, "</ServerSettings>", "")
Local $sConfigFileTempExists = FileExists($aConfigFileTempFull)
If $sConfigFileTempExists = 1 Then
FileDelete($aConfigFileTempFull)
EndIf
FileWrite($aConfigFileTempFull, $tConfigRead1)
; **** Append Server Version to Server Name ****
If ($aAppendVerBegin = "no") And ($aAppendVerEnd = "no") Then
$aServerNameVer = $aServerName
Else
If $aGameVer = "[Unable to retrieve]" Then
$aServerNameVer = $aServerName
Else
If $aAppendVerShort = "short" Then
$aGameVerTemp1 = $aGameVer
$aGameVerTemp1 = _StringBetween($aGameVerTemp1, "(", ")")
$aGameVer = _ArrayToString($aGameVerTemp1)
EndIf
$aServerNameVer = $aServerName
If $aAppendVerBegin = "yes" Then
$aServerNameVer = $aGameVer & $aServerNameVer
EndIf
If $aAppendVerEnd = "yes" Then
$aServerNameVer = $aServerNameVer & $aGameVer
EndIf
EndIf
$aPropertyName = "ServerName"
FileWriteLine($aConfigFileTempFull, "<property name=""" & $aPropertyName & """ value=""" & $aServerNameVer & """/>")
IniWrite($aUtilCFGFile, "CFG", "Last Server Name", $aServerNameVer)
EndIf
If $aServerNamFromLog = $aServerNameVer Then
LogWrite("", " [Server] Running server name contains correct server name. No restart necessary. [" & $aServerNameVer & "]")
Else
If $aServerNamFromLog = "[Unable to retrieve]" Then
ControlSetText($aSplash, "", "Static1", "Server Started." & @CRLF & @CRLF & "Unable to retrieve server name from log.")
Sleep(5000)
Else
$tRebootTF = True
LogWrite("", " [Server] Changing Server Name to [" & $aServerNameVer & "]. Reboot necessary")
EndIf
EndIf
EndIf
If $aWipeServer = "no" Then
$aGameName = "[no change]"
Else
Local $tGameName = IniRead($aUtilCFGFile, "CFG", "Last Game Name", $aFPGameName)
$aPropertyName = "GameName"
$aGameName = StringRegExpReplace($aGameVer, "[\(\)]", "")
FileWriteLine($aConfigFileTempFull, "<property name=""" & $aPropertyName & """ value=""" & $aGameName & """/>")
LogWrite("", " [Server] Changing GameName to """ & $aGameName & """ in " & $aConfigFileTempFull & ".")
IniWrite($aUtilCFGFile, "CFG", "Last Game Name", $aGameName)
If $tGameName = $aGameName Then
LogWrite(" [Server] Running server Game Name = Appended server Game Name. No restart necessary.", " [Server] Running server Game Name = Appended server Game Name. No restart necessary. [" & $aGameName & "]")
Else
$tRebootTF = True
EndIf
EndIf
If $aAppendVerBegin = "yes" Or $aAppendVerEnd = "yes" Or $aWipeServer = "yes" Then
FileWriteLine($aConfigFileTempFull, "<property name=""TelnetEnabled"" value=""" & $aServerTelnetEnable & """/>")
FileWriteLine($aConfigFileTempFull, "<property name=""TelnetPort"" value=""" & $aTelnetPort & """/>")
FileWriteLine($aConfigFileTempFull, "<property name=""TelnetPassword"" value=""" & $aTelnetPass & """/>")
FileWriteLine($aConfigFileTempFull, "</ServerSettings>")
EndIf
If $aQueryYN = "no" Then $aServerQueryName = $aServerNamFromLog
If $tRebootTF Then
ControlSetText($aSplash, "", "Static1", "Restarting server to apply config change(s)." & @CRLF & "Server name: " & $aServerNameVer & @CRLF & "Game Name: " & $aGameName)
LogWrite(" [Server] ----- Restarting server to apply config change(s).")
$aRebootConfigUpdate = "yes"
$aRebootMe = "no"
$aServerTelnetReboot = "no"
CloseServer($aTelnetIP, $aTelnetPort, $aTelnetPass)
EndIf
SplashOff()
Else
LogWrite("", " [Server} Notice! Utility reported server PID(" & $aServerPID & ") not running, but searched and found a running server PID(" & $tReturn & "). New PID assigned.")
$aServerPID = $tReturn
SplashOff()
EndIf
If @error Or Not $aServerPID Then
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(262405, "Server Failed to Start", "The server tried to start, but it failed. Try again? This will automatically close in 60 seconds and try to start again.", 60)
Select
Case $iMsgBoxAnswer = 4 ;Retry
LogWrite(" [" & $aServerName & " (PID: " & $aServerPID & ")] Server Failed to Start. User Initiated a Restart Attempt.")
Case $iMsgBoxAnswer = 2 ;Cancel
LogWrite(" [" & $aServerName & " (PID: " & $aServerPID & ")] Server Failed to Start - " & $aUtilName & " Shutdown - Initiated by User")
_ExitUtil()
Case $iMsgBoxAnswer = -1 ;Timeout
LogWrite(" [" & $aServerName & " (PID: " & $aServerPID & ")] Server Failed to Start. Script Initiated Restart Attempt after 60 seconds of no User Input.")
EndSelect
EndIf
IniWrite($aUtilCFGFile, "CFG", "PID", $aServerPID)
#EndRegion ;**** Watchdog and Server Start, Rename, Update, etc. ****
#Region ;**** Watchdog Disabled ****
ElseIf ((_DateDiff('n', $aTimeCheck1, _NowCalc())) >= 5) Then
; If $aExMemRestart = "yes" Then
If ProcessExists($aServerPID) Then
Local $MEM = ProcessGetStats($aServerPID, 0)
If @error Then
Else
If $MEM[0] > $aExMemAmt And $aExMemRestart = "yes" Then
LogWrite(" [" & $aServerName & " (PID: " & $aServerPID & ")] Work Memory:" & $MEM[0] & " Peak Memory:" & $MEM[1] & " Excessive Memory Use - Restart requested by " & $aUtilName & " Script", " [" & $aServerName & " (PID: " & $aServerPID & ")] Work Memory:" & $MEM[0] & " Peak Memory:" & $MEM[1])
CloseServer($aTelnetIP, $aTelnetPort, $aTelnetPass)
EndIf
EndIf
$aTimeCheck1 = _NowCalc()
Else
EndIf
EndIf
#EndRegion ;**** Watchdog Disabled ****
#Region ;**** If Query Port Disabled, Get Server Name From Log ****
If $aQueryYN = "no" And $tQueryLogReadDoneTF = False Then
Local $tDiffStart = _DateDiff('n', $gWatchdogServerStartTimeCheck, _NowCalc())
If $tDiffStart < 1 Then
Else
$aServerNamFromLog = _GetServerNameFromLog($aSplash)
$tQueryLogReadDoneTF = True
EndIf
EndIf
#EndRegion ;**** If Query Port Disabled, Get Server Name From Log ****
#Region ;**** Online Player Check & Horde Day Announcements ****
If $aServerOnlinePlayerYN = "yes" And $aServerShuttingDownTF = False Then
If ((_DateDiff('s', $aTimeCheck8, _NowCalc())) >= $aServerOnlinePlayerSec) Then _OnlinePlayerCheck()
EndIf
#EndRegion ;**** Online Player Check & Horde Day Announcements ****
#Region ;**** Restart Server Every X Days and X Hours & Min****
;~ If (($aRestartDaily = "yes") And ((_DateDiff('n', $aTimeCheck2, _NowCalc())) >= 1) And (DailyRestartCheck($aRestartDays, $aRestartHours, $aRestartMin)) And ($aBeginDelayedShutdown = 0)) And $aServerShuttingDownTF = False Then
If $aRestartDaily = "yes" And (_DateDiff('n', $aTimeCheck2, _NowCalc())) >= 1 And DailyRestartCheck($aRestartDays, $aRestartHours, $aRestartMin) And $aServerShuttingDownTF = False Then
If ProcessExists($aServerPID) Then
Local $MEM = ProcessGetStats($aServerPID, 0)
If @error Then
Else
LogWrite(" [" & $aServerName & " (PID: " & $aServerPID & ")] Work Memory:" & $MEM[0] & " Peak Memory:" & $MEM[1] & " - Daily restart requested by " & $aUtilName & ".")
EndIf
If $aDelayShutdownTime Not = 0 Then
$aBeginDelayedShutdown = 1
$aRebootReason = "daily"
$aTimeCheck0 = _NowCalc
$aAnnounceCount1 = $aAnnounceCount1 + 1
Else
RunExternalScriptDaily()
CloseServer($aTelnetIP, $aTelnetPort, $aTelnetPass)
EndIf
EndIf
$aTimeCheck2 = _NowCalc()