def exec_all_registered(event_name): import es exec_cmd = execmd_cvar.get_string() script_dir = scriptdir_cvar.get_string() # Execute root scripts cfg_path = '{}/{}.cfg'.format(script_dir, event_name) if GAME_PATH.joinpath('cfg', cfg_path).exists(): es.dbgmsg(2, 'Sending {} command for {}.'.format(exec_cmd, event_name)) queue_server_command(exec_cmd, cfg_path) # Execute cfg scripts es.dbgmsg(2, 'Script pack registration scanning...') for scriptpack, enabled in cfg_scripts.items(): if not enabled: continue cfg_path = '{}/{}/{}.cfg'.format(script_dir, scriptpack, event_name) if GAME_PATH.joinpath('cfg', cfg_path).exists(): es.dbgmsg(2, 'Sending {} command for {}.'.format(exec_cmd, cfg_path)) queue_server_command(exec_cmd, cfg_path) else: es.dbgmsg(1, 'File doesn\'t exist: {}'.format(cfg_path)) # Execute Python addons es.dbgmsg(2, 'Checking all scripts...') es.addons.triggerEvent(event_name)
def game_start(self, player_index: int, game_mode, api): if api.input_json['weapon_for_user']: self.player_weapon = api.input_json['weapon_for_user'] sdm_logger.debug(f'Current player from backend {self.player_weapon}') else: sdm_logger.debug(f'No weapon for player from backend Leaving {self.player_weapon}') if api.input_json['weapon_for_bot'] and api.input_json['weapon_for_bot'] != "weapon_knife": self.bot_weapon = api.input_json['weapon_for_bot'] sdm_logger.debug(f'Current bot from backend {self.bot_weapon}') else: sdm_logger.debug(f'No weapon for bot from backend Leaving {self.bot_weapon}') game_mode.single_start = True ConVar('mp_roundtime').set_int(api.input_json["game_time"] // 60) # in minutes ConVar('mp_round_restart_delay').set_int(14) ConVar('mp_teammates_are_enemies').set_int(0) ConVar('bot_difficulty').set_int(api.input_json.get("difficulty", 1)) sdm_logger.info(f"Bot difficulty is set to {ConVar('bot_difficulty').get_int()}") queue_server_command('bot_kick') queue_server_command('mp_warmup_end') if not self.state_warmup: self.spawn_enemies(player_index, api) #sdm_logger.debug(f'Restriction of {bot_team[player.team]} team from {self.player_weapon} is done') else: sdm_logger.error('Warmup was not finished. Skipping game start.')
def kick(self, message=''): """Kick the player from the server. :param str message: A message the kicked player will receive. """ message = message.rstrip() if message: self.client.disconnect(message) else: queue_server_command('kickid', self.userid, message)
def ban(self, duration=0, kick=True, write_ban=True): """Ban a player from the server. :param int duration: Duration of the ban in minutes. Use 0 for permament. :param bool kick: If ``True``, the player will be kicked as well. :param bool write_ban: If ``True``, the ban will be written to ``cfg/banned_users.cfg``. """ queue_server_command( 'banid', duration, self.userid, 'kick' if kick else '') if write_ban: queue_server_command('writeid')
def ban(self, duration=0, kick=True, write_ban=True): """Ban a player from the server. :param int duration: Duration of the ban in minutes. Use 0 for permament. :param bool kick: If ``True``, the player will be kicked as well. :param bool write_ban: If ``True``, the ban will be written to ``cfg/banned_users.cfg``. """ queue_server_command('banid', duration, self.userid, 'kick' if kick else '') if write_ban: queue_server_command('writeid')
def on_changelevel(command): if mapcommands_cvar.get_int() <= 0: return new_map = nextmap_cvar.get_string() if new_map in ('', '0') or len(command) <= 1: return import es nextmap_cvar.set_string('') queue_server_command('changelevel', new_map) es.dbgmsg( 0, '[EventScripts] Next map changed from {} to {}.'.format( command[1], new_map)) return CommandReturn.BLOCK