def init(): # Config.show_keep_alive_after_idle = 1 Config = Factory.get('Config') Lang = Factory.get('Translation') try: Config.printSettings() if not ServerControl.is_server_running(): out(Lang.get('server_not_running')) ServerControl.start_server() custom_import(Config.events_config,'events') #Load events Rcon.init(Config.rcon_host, Config.rcon_port, Config.query_port, Config.rcon_password, Config.rcon_socket_timeout) #custom_import(Config.events_config,'input') #Load terminal input configuration custom_import(Config.tasks_config,'tasks') #Load tasks custom_import(Config.chatcmds_config,'chatcmds') #Load chat commands if not Factory.has('GUI'): InputHandler.init() #Activate listening for terminal input # Prevent threads from dying due to early main completed execution. while True: if Storage.terminate_application is True: exit() time.sleep(1) # Important part of not being a CPU hog. except KeyboardInterrupt: Storage.terminate_application = True
def get_version(cls): data = Rcon.query_server() if data: if Factory.has('GUI_CONTROL'): Factory.get('GUI_CONTROL').set_server_version(data['game_version']) out('Server is running game version: ', data['game_version']) else: out('Unable to retrieve server game version')
def out(*args,**kwargs): if Config.display_output is False: return Storage.last_output_unix_time = time.time() text = "{} [{}] # ".format(time_str(), len(Storage.players_online_steam_name)) if Factory.has('GUI'): GUI = Factory.get('GUI') if GUI: print(text,*args,**kwargs,file=GUI) else: print(text,*args,**kwargs) if log_defined(): log = get_log_file_handle() if log: print(text,*args,**kwargs,file=log, flush=True) debug_log = get_log_file_handle(True) if log: print(text,*args,**kwargs,file=debug_log, flush=True)
def keep_alive(cls): if Factory.has('GUI_CONTROL'): Factory.get('GUI_CONTROL').set_last_keepalive()
def server_last_response(cls): if Factory.has('GUI_CONTROL'): Factory.get('GUI_CONTROL').set_last_serverresponse()
def update_gui_listplayers(cls,player_list): if Factory.has('GUI_CONTROL'): Factory.get('GUI_CONTROL').update_playerlist()