Exemplo n.º 1
0
    def execute(self, name, event=None, define=False):
        if self.settings.type is ModuleType.SP:
            callback = _race_callbacks.get(self.name, {}).get(name)

            if callback is not None:
                if event is None:
                    callback(self.wcsplayer)
                else:
                    callback(event, self.wcsplayer)
        elif self.settings.type is ModuleType.ESP:
            callback = es.addons.Blocks.get(
                f'wcs/modules/races/{self.name}/{name}')

            if callback is not None:
                if event is None:
                    callback(self.wcsplayer)
                else:
                    callback(es.event_var, self.wcsplayer)
        elif self.settings.type is ModuleType.ESS:
            if define:
                cvar_wcs_userid.set_int(self.wcsplayer.userid)

            addon = esc.addons.get(f'wcs/modules/races/{self.name}')

            if addon is not None:
                executor = addon.blocks.get(name)

                if executor is not None:
                    executor.run()
        elif self.settings.type is ModuleType.ESS_INI or self.settings.type is ModuleType.ESS_KEY:
            commands = self.settings.cmds.get(name)

            if commands is not None and commands:
                for cmd in commands.split(';'):
                    execute_server_command(*split(cmd))
Exemplo n.º 2
0
def wcs_nearcoord_command(command_info, var:str, players:convert_identifier_to_players, x:float, y:float, z:float, distance:float, command:str):
    vector = Vector(x, y, z)

    for player in players:
        if vector.get_distance(player.origin) <= distance:
            for cmd in [f'es_xset {var} {player.userid}'] + command.split(';'):
                execute_server_command(*split(cmd))
Exemplo n.º 3
0
    def execute(self, name, module, callbacks, args):
        if self.type is ModuleType.SP:
            callback = callbacks.get(self.name, {}).get(name, None)

            if callback is not None:
                callback(*args)
        elif self.type is ModuleType.ESP:
            callback = es.addons.Blocks.get(
                f'wcs/modules/{module}/{self.name}/{name}')

            if callback is not None:
                callback(*args)
        elif self.type is ModuleType.ESS:
            addon = esc.addons.get(f'wcs/modules/{module}/{self.name}')

            if addon is not None:
                executor = addon.blocks.get(name)

                if executor is not None:
                    executor.run()
        elif self.type is ModuleType.ESS_INI or self.type is ModuleType.ESS_KEY:
            commands = self.cmds.get(name)

            if commands is not None and commands:
                for cmd in commands.split(';'):
                    execute_server_command(*split(cmd))
Exemplo n.º 4
0
    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:
            execute_server_command('kickid', self.userid, message)
Exemplo n.º 5
0
def load():
    # Save the bot quota
    global bot_quota
    bot_quota = cvar_bot_quota.get_int()

    # Kick all bots so that our hooks don't crash the server
    execute_server_command('tf_bot_kick', 'all')

    # Restart the round to get bots back again
    cvar_restartgame.set_int(1)

    broadcast(common_strings['loaded'])
Exemplo n.º 6
0
    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``.
        """
        execute_server_command(
            'banid', duration, self.userid, 'kick' if kick else '')
        if write_ban:
            execute_server_command('writeid')
Exemplo n.º 7
0
    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``.
        """
        execute_server_command('banid', duration, self.userid,
                               'kick' if kick else '')
        if write_ban:
            execute_server_command('writeid')
Exemplo n.º 8
0
def checkBuy(userid, item):
    userid = int(userid)
    iteminfo = wcs.wcs.ini.getItems[wcs.wcs.itemdb.getSectionFromItem(
        item)][item]
    player_entity = Player(index_from_userid(userid))
    if player_entity.dead:
        is_dead = 0
    else:
        is_dead = 1
    if is_dead == int(iteminfo['dab']) or int(iteminfo['dab']) == 2:
        ConVar('wcs_userid').set_int(userid)
        ConVar('wcs_dice').set_int(random.randint(0, 100))
        if iteminfo['cfg'] == 'player_buy' and iteminfo['cmdactivate']:
            settings = iteminfo['cmdactivate']
            if ';' in settings:
                sub_settings = settings.split(';')
                for com in sub_settings:
                    execute_server_command('es', com)
            else:
                execute_server_command('es', settings)
        elif iteminfo['cmdbuy']:
            settings = iteminfo['cmdbuy']
            if ';' in settings:
                sub_settings = settings.split(';')
                for com in sub_settings:
                    execute_server_command('es', com)
            else:
                execute_server_command('es', settings)
Exemplo n.º 9
0
def _sp_help(command_info, command=None, *server_sub_commands):
    """Print all sp sub-commands or help for a specific command."""
    if command is None:
        execute_server_command('sp')
        return

    commands = (command, ) + server_sub_commands
    try:
        node = TypedServerCommand.parser.get_node(commands)
    except ValueError:
        core_command_logger.log_message('Command "{}" does not exist.'.format(
            ' '.join(commands)))
        return

    core_command_logger.log_message(node.signature)
    if node.description is not None:
        core_command_logger.log_message('  ' + node.description)
def _sp_help(command_info, command=None, *server_sub_commands):
    """Print all sp sub-commands or help for a specific command."""
    if command is None:
        execute_server_command('sp')
        return

    commands = (command,) + server_sub_commands
    try:
        node = TypedServerCommand.parser.get_node(commands)
    except ValueError:
        core_command_logger.log_message(
            'Command "{}" does not exist.'.format(' '.join(commands)))
        return

    core_command_logger.log_message(node.signature)
    if node.description is not None:
        core_command_logger.log_message('  ' + node.description)
Exemplo n.º 11
0
def checkEvent(userid, event):
    userid = int(userid)
    player = Player.from_userid(userid)
    if player.team > 1:
        if userid in items:
            if event in items[userid]:
                for item in items[userid][event]:
                    v = items[userid][event][item]
                    item, section = item, wcs.wcs.itemdb.getSectionFromItem(
                        item)
                    iteminfo = wcs.wcs.ini.getItems[section][item]

                    ConVar('wcs_userid').set_int(userid)
                    ConVar('wcs_dice').set_int(random.randint(0, 100))

                    while v > 0:
                        if (iteminfo['cfg'] == 'player_buy' or event
                                == 'player_buy') and iteminfo['cmdbuy']:
                            settings = str(iteminfo['cmdbuy'])
                            if ';' in settings:
                                sub_settings = settings.split(';')
                                for com in sub_settings:
                                    execute_server_command('es', com)
                            else:
                                execute_server_command('es', settings)

                        elif iteminfo['cmdactivate']:
                            settings = str(iteminfo['cmdactivate'])
                            if ';' in settings:
                                sub_settings = settings.split(';')
                                for com in sub_settings:
                                    execute_server_command('es', com)
                            else:
                                execute_server_command('es', settings)
                            wcs.wcs.tell(
                                userid, '\x04[WCS] %s \x05activated!' %
                                iteminfo['name'])

                        v -= 1
Exemplo n.º 12
0
def give(userid, entity):
    userid = int(userid)
    execute_server_command('es_give', '%s %s' % (userid, entity))
Exemplo n.º 13
0
def _command(command):
    alias = command.command_string.strip()

    if alias in _aliases:
        for cmd in _aliases[alias].split(';'):
            execute_server_command('es', cmd)
Exemplo n.º 14
0
    def kick(self, message=''):
        """Kick the player from the server.

        :param str message: A message the kicked player will receive.
        """
        execute_server_command('kickid', self.userid, message.rstrip())
Exemplo n.º 15
0
    def notify(self, event, name=None):
        if name is None:
            name = event.name

        for skill_name, data in self.settings.config['skills'].items():
            if name in data['event']:
                skill = self.skills[skill_name]
                level = skill.level

                if level:
                    variables = {}

                    for variable, values in skill.config['variables'].items():
                        variables[variable] = values[
                            level - 1] if level <= len(values) else values[-1]

                    if skill._type is ModuleType.SP:
                        callback = _race_callbacks.get(self.name,
                                                       {}).get(skill_name,
                                                               {}).get(name)

                        if callback is not None:
                            if event is None:
                                callback(self.wcsplayer, variables)
                            else:
                                callback(event, self.wcsplayer, variables)
                    elif skill._type is ModuleType.ESP:
                        callback = es.addons.Blocks.get(
                            f'wcs/modules/races/{self.name}/{skill_name}')

                        if callback is not None:
                            if event is None:
                                callback(self.wcsplayer, variables)
                            else:
                                callback(es.event_var, self.wcsplayer,
                                         variables)
                    elif skill._type is ModuleType.ESS:
                        addon = esc.addons.get(
                            f'wcs/modules/races/{self.name}')

                        if addon is not None:
                            executor = addon.blocks.get(skill_name)

                            if executor is not None:
                                for cvar in cvar_wcs_dices:
                                    cvar.set_int(randint(0, 100))

                                for variable, values in variables.items():
                                    variable = f'wcs_{variable}'
                                    cvar = cvars.get(variable)

                                    if cvar is None:
                                        cvar = cvars[variable] = ConVar(
                                            variable, '0')

                                    if isinstance(values, list):
                                        if isinstance(values[0],
                                                      float) or isinstance(
                                                          values[1], float):
                                            cvar.set_float(uniform(*values))
                                        else:
                                            cvar.set_int(randint(*values))
                                    else:
                                        if isinstance(values, float):
                                            cvar.set_float(values)
                                        else:
                                            cvar.set_int(values)

                                executor.run()
                    elif skill._type is ModuleType.ESS_INI or skill._type is ModuleType.ESS_KEY:
                        for cvar in cvar_wcs_dices:
                            cvar.set_int(randint(0, 100))

                        try:
                            commands = skill.config['cmds']['setting'][level -
                                                                       1]
                        except IndexError:
                            commands = skill.config['cmds']['setting'][-1]

                        if commands:
                            for cmd in commands.split(';'):
                                execute_server_command(*split(cmd))

                        for key in ('cmd', 'sfx'):
                            commands = skill.config['cmds'][key]

                            if commands:
                                for cmd in commands.split(';'):
                                    execute_server_command(*split(cmd))

        for item in self.wcsplayer.items.values():
            if name in self.settings.config['event']:
                if self.settings.type is ModuleType.SP:
                    callback = _item_callbacks.get(self.name, {}).get(name)

                    if callback is not None:
                        if event is None:
                            callback(self.wcsplayer)
                        else:
                            callback(event, self.wcsplayer)
                elif self.settings.type is ModuleType.ESP:
                    callback = es.addons.Blocks.get(
                        f'wcs/modules/items/{self.name}/{name}')

                    if callback is not None:
                        if event is None:
                            callback(self.wcsplayer)
                        else:
                            callback(es.event_var, self.wcsplayer)
                elif self.settings.type is ModuleType.ESS:
                    addon = esc.addons.get(f'wcs/modules/items/{self.name}')

                    if addon is not None:
                        executor = addon.blocks.get(name)

                        if executor is not None:
                            executor.run()
                elif self.settings.type is ModuleType.ESS_INI or self.settings.type is ModuleType.ESS_KEY:
                    commands = self.settings.cmds.get(name)

                    if commands is not None and commands:
                        for cmd in commands.split(';'):
                            execute_server_command(*split(cmd))
Exemplo n.º 16
0
    def execute(self, name=None, event=None, define=False):
        if self.level:
            variables = {}

            for variable, values in self.config['variables'].items():
                variables[variable] = values[
                    self.level -
                    1] if self.level <= len(values) else values[-1]

            if self._type is ModuleType.SP:
                callback = _race_callbacks.get(self._race_name,
                                               {}).get(self.name,
                                                       {}).get(name
                                                               or event.name)

                if callback is not None:
                    if event is None:
                        callback(self.wcsplayer, variables)
                    else:
                        callback(event, self.wcsplayer, variables)
            elif self._type is ModuleType.ESP:
                callback = es.addons.Blocks.get(
                    f'wcs/modules/races/{self._race_name}/{self.name}')

                if callback is not None:
                    if event is None:
                        callback(self.wcsplayer, variables)
                    else:
                        callback(es.event_var, self.wcsplayer, variables)
            elif self._type is ModuleType.ESS:
                addon = esc.addons.get(f'wcs/modules/races/{self._race_name}')

                if addon is not None:
                    executor = addon.blocks.get(self.name)

                    if executor is not None:
                        if define:
                            cvar_wcs_userid.set_int(self.wcsplayer.userid)

                        for cvar in cvar_wcs_dices:
                            cvar.set_int(randint(0, 100))

                        for variable, values in variables.items():
                            variable = f'wcs_{variable}'
                            cvar = cvars.get(variable)

                            if cvar is None:
                                cvar = cvars[variable] = ConVar(variable, '0')

                            if isinstance(values, list):
                                if isinstance(values[0], float) or isinstance(
                                        values[1], float):
                                    cvar.set_float(uniform(*values))
                                else:
                                    cvar.set_int(randint(*values))
                            else:
                                if isinstance(values, float):
                                    cvar.set_float(values)
                                else:
                                    cvar.set_int(values)

                        executor.run()
            elif self._type is ModuleType.ESS_INI or self._type is ModuleType.ESS_KEY:
                if define:
                    cvar_wcs_userid.set_int(self.wcsplayer.userid)

                for cvar in cvar_wcs_dices:
                    cvar.set_int(randint(0, 100))

                try:
                    commands = self.config['cmds']['setting'][self.level - 1]
                except IndexError:
                    commands = self.config['cmds']['setting'][-1]

                if commands:
                    for cmd in commands.split(';'):
                        execute_server_command(*split(cmd))

                for key in ('cmd', 'sfx'):
                    commands = self.config['cmds'][key]

                    if commands:
                        for cmd in commands.split(';'):
                            execute_server_command(*split(cmd))
Exemplo n.º 17
0
def on_restart(command_info):
    alert(f"Server will restart in {ORANGE}10 {WHITE}seconds by admin request")
    Delay(10, lambda: execute_server_command("_restart"))
Exemplo n.º 18
0
def wcs_pushto_command(command_info, *args):
    if len(args) == 5:
        execute_server_command('_wcs_pushto', args[0], ','.join(args[1:3]), args[4])
    else:
        execute_server_command('_wcs_pushto', *args)
Exemplo n.º 19
0
def wcs_dalias_command(command_info, alias:str, *args:str):
    for i, value in enumerate(args, 1):
        ConVar(f'wcs_tmp{i}').set_string(value)

    for cmd in _aliases[alias].split(';'):
        execute_server_command(*split(cmd))
Exemplo n.º 20
0
def wcs_xalias_command(command_info, alias:str, command:str=None):
    if command is None:
        for cmd in _aliases[alias].split(';'):
            execute_server_command(*split(cmd))
    else:
        _aliases[alias] = command
Exemplo n.º 21
0
def unload():
    # Kick all bots so that our hooks don't crash the server
    execute_server_command('tf_bot_kick', 'all')

    broadcast(common_strings['unloaded'])
Exemplo n.º 22
0
def wcs_foreach_command(command_info, var:str, players:convert_identifier_to_players, command:str):
    for player in players:
        for cmd in [f'es_xset {var} {player.userid}'] + command.split(';'):
            execute_server_command(*split(cmd))
Exemplo n.º 23
0
    def kick(self, message=''):
        """Kick the player from the server.

        :param str message: A message the kicked player will receive.
        """
        execute_server_command('kickid', self.userid, message.rstrip())