SpencerXZX Posted May 4, 2019 Share Posted May 4, 2019 Thought I would share my autosave program, it's super simple and only saves the game. No error handling set up or anything, just barebones basic. Maybe it will be useful to some. It was programmed using Python2.7 but may be compatible with other versions. Here's the code (save it as a .py file): # Main import telnetlib import sys # # 7D2D Telnet Info HOST = "localhost" password = "password" port = "8081" debug = True def main(): # Start Main try: server_connect() savegame() except KeyboardInterrupt: sys.exit(0) return def server_connect(): # Connect telnet client. global SDTDTelnet if debug: print'Connecting to Server...' # SDTDTelnet = telnetlib.Telnet(HOST, port) SDTDTelnet.read_until("password:") SDTDTelnet.write(password + "\n") if debug: print'Connected.' return def savegame(): # Save game and return. SDTDTelnet.write('saveworld' + '\n') telnetoutput = "" while 'World saved' not in telnetoutput: telnetoutput = SDTDTelnet.read_until("\n") telnetoutput = telnetoutput.translate(None, '\n') if 'World saved' in telnetoutput: print'World Saved Successfully.' return main() I'm using it with a cron job every 24 hours. After I run this I restart the server, that way no data is lost during the restart. Connecting to the telnet client through Python is very powerful, you could easily warn your users that the server was about to restart, shutdown the server before the host power down, etc.. Make sure to replace "localhost" with your server IP or hostname, as well as configure the password and port. This will only work if you have telnet enabled on your SDTD server. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.