I have written a script to interface with a dos command window that I call the Halo server window. This server window allows you to enter dos commands to change or display values in a Halo dedicated server game play. The default commands to start the server window are stored in the init.txt file located in the Halo Server directory.
This is the contents of the init.txt file. The sv_commands on the left are the actual commands the server window uses to change the values to the right of the sv_command. For instance the
sv_name(Server Name) command in the first line has a value of
Halo_DS.
Code:
sv_name Halo_DS
sv_public 1
sv_maxplayers 12
sv_password halo
sv_mapcycle_add bloodgulch "Done Slayer"
sv_mapcycle_add timberland "team king"
sv_mapcycle_add damnation "team slayer"
sv_mapcycle_add dangercanyon ctf
sv_mapcycle_add carousel slayer
sv_mapcycle_add gephyrophobia slayer
sv_mapcycle_add infinity "classic rockets"
sv_mapcycle_begin
sv_rcon_password test
These sv_commands are entered by typing the text in the dos command prompt in the server window. By clicking on the buttons from my Gui window in my script the sv_command is entered in for me. All that is left then is to enter the actual value you wish to change and pressing enter to finish the command. After I click on one of my buttons to enter the sv_command and enter the command value the server window tells me it has accepted the value correctly.
Example: I click on the
Server Name button from my Gui window to change the name of my server and it displays the change correctly.
My problem is this. The sv_command values I enter are not save in the init.txt file. So the next time I want to run the server it displays the old value of the server name -
sv_name Halo_DS as shown above in the init.txt file.
This is my script to interface with the server window.
Code:
#NoEnv
#InstallKeybdHook
#InstallMouseHook
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#usehook
DetectHiddenWindows, On
Run Haloded.exe
Gui, Default
Menu, FileMenu, Add, &Edit Init File, MenuFileEdit ; See remarks below about Ctrl+O.
Menu, FileMenu, Add, E&xit, MenuHandler
Menu, HelpMenu, Add, &About, MenuHandler
Menu, MyMenuBar, Add, &File, :FileMenu ; Attach the two sub-menus that were created above.
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar
Gui, Font, S14 CBlue Bold, Verdana
Gui, Add, Text, x16 y10 w210 h30 +Center, Halo GUI Server
Gui, Font, S9 Cmaroon Bold, Verdana
Gui, Add, GroupBox, x6 y40 w110 h190 vServerControl, Server Control
Gui, Add, Groupbox, x121 y40 w110 h190 vMapControl, Map Control
Gui, Add, GroupBox, x6 y235 w225 h150 vPlayerControl, Player Control
Gui, Font
Gui, Add, Button, Group x11 y65 w100 h20 gClearScreen, Clear Screen
Gui, Add, Button, x11 y85 w100 h20 gServerName vServerName, Server Name
Gui, Add, Button, x11 y105 w100 h20 gServerPassword vServerPassword, Server Password
Gui, Add, Button, x11 y125 w100 h20 gPublicServer vPublicServer, Public Server
Gui, Add, Button, x11 y145 w100 h20 gRconPassword vRconPassword, Rcon Password
Gui, Add, Button, x11 y165 w100 h20 gServerStatus, Server Status
Gui, Add, Button, x11 y185 w100 h20 gEndGame, End Game
Gui, Add, Button, x11 y205 w100 h20 gQuit, Quit
Gui, Add, Button, Group x126 y65 w100 h20 gStartMapcycle, Start Mapcycle
Gui, Add, Button, x126 y85 w100 h20 gCurrentMaps, Current Maps
Gui, Add, Button, x126 y105 w100 h20 gAddMap vAddMap, Add Map
Gui, Add, Button, x126 y125 w100 h20 gDeleteMap, Delete Map
Gui, Add, Button, x126 y145 w100 h20 gNextMap, Next Map
Gui, Add, Button, x126 y165 w100 h20 gChooseMap, Choose Map
Gui, Add, Button, x126 y185 w100 h20 gResetMap, Restart Map
Gui, Add, Button, x126 y205 w100 h20 gMapcycleTime vMapcycleTime, Mapcycle Timeout
Gui, Add, Button, Group x11 y260 w100 h20 gShowPlayers, Show Players
Gui, Add, Button, x11 y280 w100 h20 gKickPlayer, Kick Player
Gui, Add, Button, x11 y300 w100 h20 gBanPlayer, Ban player
Gui, Add, Button, x11 y320 w100 h20 gUnbanPlayer, Unban Player
Gui, Add, Button, x11 y340 w100 h20 gBanList, Ban List
Gui, Add, Button, x11 y360 w100 h20 gBanlistFile, Ban List File
Gui, Add, Button, x126 y260 w100 h20 gMaxPlayers vMaxPlayers, Maximum Players
Gui, Add, Button, x126 y280 w100 h20 gTeamKillingPoint vTeamKillingPoint, Team Kill Point
Gui, Add, Button, x126 y300 w100 h20 gTeamKillPentalty vTeamKillPentalty, Team Kill Pentalty
Gui, Add, Button, x126 y320 w100 h20 gTeamKillGrace vTeamKillGrace, Team Kill Grace
Gui, Add, Button, x126 y340 w100 h20 gTeamKillCooldown vTeamKillCooldown, Team Kill Cooldown
Gui, Show, x770 h390 w235, Dedicated Server
Return
MenuFileEdit:
Return
MenuHandler:
Return
ClearScreen:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, cls
Sleep 500
SendPlay, {Enter}
Gui, Show, Dedicated Server
Return
ServerName:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}name{Space}
Sleep 500
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
ServerPassword:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}password{Space}
Sleep 500
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
PublicServer:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}public{Space}
Sleep 500
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
RconPassword:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}rcon{SHIFTDOWN}-{SHIFTUP}password{Space}
Sleep 500
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
ServerStatus:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}status{Space}
Sleep 500
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
EndGame:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}end{SHIFTDOWN}-{SHIFTUP}game{Enter}
Sleep 500
Gui, Show, Dedicated Server
Return
Quit:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, quit{Enter}
WinWaitClose Halo Console
ExitApp
Return
StartMapcycle:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle_begin
Sleep 500
SendPlay, {Enter}
Gui, Show, Dedicated Server
Return
CurrentMaps:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle
Sleep 500
SendPlay, {Enter}
Gui, Show, Dedicated Server
Return
AddMap:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}maplist
Sleep 500
SendPlay, {Enter}
Sleep 500
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle_add{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
DeleteMap:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle
Sleep 500
SendPlay, {Enter}
Sleep 500
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle_del{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
NextMap:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}map_next
Sleep 500
SendPlay, {Enter}
Gui, Show, Dedicated Server
Return
ChooseMap:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle
Sleep 500
SendPlay, {Enter}
Sleep 500
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}map{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
ResetMap:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}map_reset
Sleep 500
SendPlay, {Enter}
Gui, Show, Dedicated Server
Return
MapcycleTime:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}mapcycle_timeout{Space}
Sleep 500
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
ShowPlayers:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}players
Sleep 500
SendPlay {Enter}
Gui, Show, Dedicated Server
Return
KickPlayer:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}players
Sleep 200
SendPlay {Enter}
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}kick{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
BanPlayer:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}players
Sleep 200
SendPlay {Enter}
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}ban{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
UnbanPlayer:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}banlist
Sleep 200
SendPlay {Enter}
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}unban{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
BanList:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}banlist
Sleep 200
SendPlay {Enter}
Gui, Show, Dedicated Server
Return
BanlistFile:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}banlist{SHIFTDOWN}-{SHIFTUP}File{Space}
Sleep 200
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
MaxPlayers:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}maxplayers{Space}
Sleep 200
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
TeamKillingPoint:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}tk{SHIFTDOWN}-{SHIFTUP}ban{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
TeamKillPentalty:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}tk{SHIFTDOWN}-{SHIFTUP}penalty{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
TeamKillGrace:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}tk{SHIFTDOWN}-{SHIFTUP}grace{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
TeamKillCooldown:
Sleep 200
WinActivate Halo Console
Sleep 200
SendPlay, sv{SHIFTDOWN}-{SHIFTUP}tk{SHIFTDOWN}-{SHIFTUP}cooldown{Space}
KeyWait, Enter,d
Gui, Show, Dedicated Server
Return
GuiClose:
ExitApp
I have tried FileAppend, InStr, and others but can't seem to get it working correctly so I changed my script back to the way it was. I need the
values only to be changed for the sv_command in the init.txt file. The only sv_command used more than once is the sv_mapcycle_add command to add new maps. Not all of the buttons need to change a variable. Some sv_commands only display values like the
Current Maps button which does not need a variable. I have placed a variable for each button that needs one. Also if a sv_command is not stored in the init.txt file, it will need to be added when used.
I have dealt with this for a while now but cannot get it to work. Any help would be greatly appreciated.