Пример #1
0
def wcs_amount_select(menu, index, choice):
    amount = int(choice.text)
    player_entity = Player(index)
    if choice.value == 'xp':
        for player in PlayerIter():
            wcs.wcs.wcsplayers[player.userid].give_xp(amount)
            wcs.wcs.tell(
                player.userid,
                '\x04[WCS] \x05You got \x04%s XP \x05from admin \x04%s!' %
                (amount, player_entity.name))
    if choice.value == 'level':
        for player in PlayerIter():
            wcs.wcs.wcsplayers[player.userid].give_level(amount)
            wcs.wcs.tell(
                player.userid,
                '\x04[WCS] \x05You got \x04%s Levels \x05from admin \x04%s!' %
                (amount, player_entity.name))
    if choice.value == 'cash':
        for player in PlayerIter():
            player.cash += amount
            wcs.wcs.tell(
                player.userid,
                '\x04[WCS] \x05You got \x04%s$ \x05from admin \x04%s!' %
                (amount, player_entity.name))
    menu.clear()
Пример #2
0
def player_death(ev):
    atk_play = Player.from_userid(ev['attacker'])
    vic_play = Player.from_userid(ev['userid'])
    if vic_play.userid == atk_play.userid or not atk_play.userid or not teambounty and vic_play.team == atk_play.team:
        return
    kills = int(wcsgroup.getUser(atk_play.userid, "wcs_bounty_kills")) + 1
    wcsgroup.setUser(atk_play.userid, "wcs_bounty_kills", kills)
    bounty = int(wcsgroup.getUser(atk_play.userid, "wcs_bounty_bounty"))
    if kills == int(streak):
        wcsgroup.setUser(atk_play.userid, "wcs_bounty_bounty", int(xpstart))
        if int(telltype):
            wcs.wcs.tell(
                atk_play.userid,
                "\x04[WCS]\x05 You started a bounty of \x04%s\x05." % xpstart)
        else:
            for player in PlayerIter():
                wcs.wcs.tell(
                    player.userid,
                    "\x04[WCS]\x05 Player \x04%s \x05has started a bounty of \x04%s\x05."
                    % (atk_play.name, xpstart))
    elif kills > int(streak):
        bounty += int(xpincrease)
        wcsgroup.setUser(atk_play.userid, "wcs_bounty_bounty", bounty)
        if int(telltype):
            wcs.wcs.tell(
                atk_play.userid,
                "\x04[WCS]\x05 Your bounty increased to \x04%s\x05." % bounty)
        else:
            for player in PlayerIter():
                wcs.wcs.tell(
                    player.userid,
                    "\x04[WCS]\x05Player \x04%s \x05bounty has increased to \x04%s\x05."
                    % (atk_play.name, bounty))
    bounty = int(wcsgroup.getUser(ev["userid"], "wcs_bounty_bounty"))
    kills = int(wcsgroup.getUser(ev["userid"], "wcs_bounty_kills"))
    if bounty and kills:
        wcs.wcs.getPlayer(atk_play.userid).giveXp(bounty, "bounty experience")
        if int(telltype):
            wcs.wcs.tell(
                atk_play.userid,
                "\x04[WCS]\x05 You stole \x05%s bounty of \x04%s\x05." %
                (vic_play.name, bounty))
            wcs.wcs.tell(
                vic_play.userid,
                "\x04[WCS]\x05 \x04%s \x05stole your bounty of \x04%s\x05." %
                (atk_play.name, bounty))
        else:
            for player in PlayerIter():
                wcs.wcs.tell(
                    player.userid,
                    "\x04[WCS]\x05 Player \x04%s\x05 has stolen \x04%s\x05 bounty of \x04%s\x05."
                    % (atk_play.name, vic_play.name, bounty))
    wcsgroup.setUser(vic_play.userid, "wcs_bounty_kills", 0)
    wcsgroup.setUser(vic_play.userid, "wcs_bounty_bounty", 0)
Пример #3
0
def index_from_accountid(accountid):
    if isinstance(accountid, str):
        for player in PlayerIter('bot'):
            if player.name == accountid:
                return player.index

        raise ValueError(accountid)

    for player in PlayerIter('human'):
        if player.raw_steamid.account_id == accountid:
            return player.index

    raise ValueError(accountid)
Пример #4
0
def convert_identifier_to_players(filter_):
    filter_ = filter_.split(',')
    is_filters = [x.replace('#', '') for x in filter_ if x.startswith('#')]
    not_filters = [x.replace('!', '') for x in filter_ if x.startswith('!')]

    for player in PlayerIter(is_filters=is_filters, not_filters=not_filters):
        yield player
Пример #5
0
def _regeneration_repeat(userid, value, maxhealth, radius):
    try:
        player = Player.from_userid(userid)
    except ValueError:
        repeats = _repeats.pop(userid, [])

        for repeat in repeats:
            if repeat.status == RepeatStatus.RUNNING:
                repeat.stop()
    else:
        if player.team not in (2, 3):
            repeats = _repeats.pop(userid, [])

            for repeat in repeats:
                if repeat.status == RepeatStatus.RUNNING:
                    repeat.stop()

            return

        if player.health < maxhealth:
            player.health = min(player.health + value, maxhealth)

        if radius:
            origin = player.origin

            for target in PlayerIter(['alive', 't' if player.team == 2 else 'ct']):
                if not target == player:
                    if target.origin.get_distance(origin) <= radius:
                        if target.health < maxhealth:
                            target.health = min(target.health + value, maxhealth)
Пример #6
0
def command_dispatch(cmd, id, client):
    if cmd[0] == "!status":
        room.send_message(
            "Name: %s\n Map: %s\n Players: %d/%d (%d bots)\n Tags: %s" %
            (server.server.name, server.server.map_name,
             server.server.num_clients,
             server.server.max_clients, server.server.num_fake_clients,
             cvar.find_var("sv_tags").get_string()))
    elif cmd[0] == "!players":
        msg = "\n".join("%s: %s" % (p.name, p.kills) for p in PlayerIter())
        room.send_message(msg if msg else "No players.")
    elif cmd[0] == "!abuse":
        room.send_message("mod abuse: " + str(mod_abuse) + "/11")
    elif cmd[0] == "!rcon":
        if id in elevated:
            server.queue_command_string(cmd[1])
        else:
            room.send_message("You do not have permission to do that.")
    elif cmd[0] == "!rm":
        if id in elevated:
            msg = client.get_message(int(cmd[1]))
            msg.delete()
        else:
            room.send_message("You do not have permission to do that.")
    elif cmd[0] == "!trash":
        if id in elevated:
            msg = client.get_message(int(cmd[1]))
            msg.move("19718")
        else:
            room.send_message("You do not have permission to do that.")
    else:
        room.send_message("No such command.")
Пример #7
0
def get_game_denial_reason(player):
    from ..lrs import config_manager as config_manager_lrs

    if not config_manager['enabled']:
        return strings_module['fail_disabled']

    if _game_instances:
        return strings_module['fail_game_already_started']

    status = get_status()
    if status == GameStatus.BUSY:
        return strings_game_status['busy']

    if status == GameStatus.NOT_STARTED:
        return strings_game_status['not_started']

    if not is_leader(player):
        return strings_module['fail_leaders_only']

    if not get_available_launchers(player, get_players_to_play()):
        return strings_module['fail_none_available']

    if (len(PlayerIter(['jail_prisoner', 'alive'])) <=
            config_manager_lrs['prisoners_limit']):

        return strings_module['fail lrs_available']

    return None
Пример #8
0
def round_end(game_event):
    """Give exp from round win and loss.

    Also executes round_end skills.
    """

    # Get the winning team
    winner = game_event.get_int('winner')

    # Loop through all the players' userids
    for userid in PlayerIter(is_filters=('ct', 't'), return_types='userid'):

        # Get the player
        player = get_player(userid)

        # Give player win exp and gold
        if player.get_team() == winner:
            give_exp(player, 'Round Win')
            give_gold(player, 'Round Win')

        # Or loss exp and gold
        else:
            give_exp(player, 'Round Loss')
            give_gold(player, 'Round Loss')

        # Execute hero's round_end skills
        player.hero.execute_skills('round_end', player=player, winner=winner)
Пример #9
0
def get_players_to_play():
    rs = []
    for player in PlayerIter(('jail_prisoner', 'alive')):
        if player.index in player_manager:
            rs.append(player_manager[player.index])

    return tuple(rs)
def round_start(game_event):
    print("Round Start")

    players = PlayerIter('human')
    for player in players:
        SayText2(message="Commands: bet, bounty").send(player)
    pass
Пример #11
0
def log_players():
    players = bots = spectators = 0

    for player in PlayerIter():
        if player.is_hltv():
            continue

        if player.is_bot():
            bots += 1
            continue
        elif player.team == 1 or player.team == 0 and not player.is_bot():
            spectators += 1
            continue
        elif not player.is_bot():
            players += 1

    global server_idle_start
    global server_idle_duration
    if players >= 1:
        server_idle_start = -1
        server_idle_duration = 0
    elif players == 0 and spectators < 4 and server_idle_start == -1:
        server_idle_start = time.time()
        server_idle_duration = 0
    elif players == 0 and spectators < 4 and server_idle_start >= 0:
        server_idle_duration = time.time() - server_idle_start

    log_value("idle", server_idle_duration)
    log_value("players", players)
    log_value("bots", bots)
    log_value("spectators", spectators)
Пример #12
0
def convert_userid_identifier_to_players(filter_):
    # TODO: Do not use es.getuserid
    userid = es.getuserid(filter_)

    try:
        index_from_userid(userid)
    except ValueError:
        players = set()
        append = True

        for x in filter_:
            if x == '#':
                append = True
            elif x == '!':
                append = False
            else:
                found_players = PlayerIter(_team_convert.get(x, x))

                if append:
                    players.update(found_players)
                else:
                    players = players.difference(found_players)

        yield from players
    else:
        yield from (Player.from_userid(userid), )
Пример #13
0
def get_leader_respawn_denial_reason(player):
    if not config_manager['enabled']:
        return strings_module['fail_disabled']

    if _round_end:
        return strings_module['fail_round_end']

    if not is_leader(player):
        return strings_module['fail_leader_required']

    status = get_status()
    if status == GameStatus.BUSY:
        return strings_module['fail_game_busy']

    if status == GameStatus.NOT_STARTED:
        return strings_module['fail_game_not_started']

    for player_ in PlayerIter(['dead', 'jail_prisoner']):
        if (player_.steamid in _rebel_steamids
                and not config_manager['allow_respawning_rebels']):

            continue

        break

    else:
        return strings_module['fail_empty']

    return None
Пример #14
0
 def get_surrounding_enemies(self):
     "Returns a list of all surrounding targets."
     return [
         player for player in PlayerIter(self.target)
         if self.origin.get_distance(player.origin) <= self.radius
         and self.can_see_entity(player)
     ]
def saycommand_bounty(playerinfo, teamonly, command):
    # bounty <player> <amount>
    params = str(command[1]).split(" ")

    if len(params) == 3:
        playername = params[1]
        amount = int(params[2])

        if amount > 0:
            # Lookup player name
            humans = PlayerIter('human', return_types=['name', 'userid'])
            playerFound = False
            for name, userid in humans:
                if name == playername:
                    playerFound = True
                    target = userid

            if playerFound:
                leetcoin_client.requestAward(-int(amount), "BOUNTY", userid_from_playerinfo(playerinfo))
                if userid in bounties:
                    bounties[userid] += amount
                else:
                    bounties[userid] = amount
                SayText2(message="BOUNTY PLACED ON " + playername).send(index_from_playerinfo(playerinfo))
            else:
                SayText2(message="Player not found").send(index_from_playerinfo(playerinfo))
    else:
        SayText2(message="Type: bounty <player> <amount>").send(index_from_playerinfo(playerinfo))
    pass
Пример #16
0
def wcs_teleport_command(command_info, player:convert_userid_to_player, x:float, y:float, z:float):
    if player is None:
        return

    location = Vector(x, y, z)
    origin = player.origin
    angles = QAngle(*player.get_property_vector('m_angAbsRotation'))

    forward = Vector()
    right = Vector()
    up = Vector()
    angles.get_angle_vectors(forward, right, up)

    forward.normalize()
    forward *= 10

    playerinfo = player.playerinfo
    mins, maxs = playerinfo.mins, playerinfo.maxs
    players = TraceFilterSimple(PlayerIter())

    for _ in range(100):
        ray = Ray(location, location, mins, maxs)
        trace = GameTrace()
        engine_trace.trace_ray(ray, ContentMasks.PLAYER_SOLID, players, trace)

        if not trace.did_hit():
            player.teleport(origin=location)
            break

        location -= forward

        if location.get_distance(origin) <= 10.0:
            break
Пример #17
0
def _regeneration_repeat(player, amount, maxhp, maxheal, radius):
    if exists(player.userid):
        if wcsgroup.getUser(player.userid, 'regeneration_active') == 1:
            if repeat_dict[player.userid] < maxheal:
                if player.health + amount <= maxhp:
                    player.health += amount
                    wcs.wcs.tell(player.userid,
                                 '\x04[WCS] \x05You got healed by a spell')
                    repeat_dict[player.userid] += amount
                else:
                    player.health = maxhp
                for play in PlayerIter('all'):
                    if play != player:
                        if play.origin.get_distance(player.origin) <= radius:
                            if play.team == player.team:
                                if (play.health + amount <= maxhp):
                                    wcs.wcs.tell(
                                        play.userid,
                                        '\x04[WCS] \x05You got healed by a spell'
                                    )
                                    play.health += amount
                                else:
                                    play.health = maxhp
        else:
            if valid_repeat(repeat_dict[player.userid]) == 1:
                if repeat_dict[player.userid].status == RepeatStatus.RUNNING:
                    repeat_dict[player.userid].stop
Пример #18
0
def wcs_ulti_roots():
    userid = int(es.ServerVar('wcs_userid'))
    player = Player.from_userid(userid)
    if player.team >= 2:
        count = 0
        wcs_commands.fade(userid, 10, 55, 5, 200, 1)
        radius = float(es.ServerVar('wcs_radius'))
        time = float(es.ServerVar('wcs_duration'))
        atk_origin = player.origin
        for play in PlayerIter('alive'):
            if play.team != player.team:
                vic_origin = play.origin
                if vic_origin.get_distance(atk_origin) <= radius:
                    if not wcsgroup.getUser(play.userid, 'ulti_immunity'):
                        play.move_type = MoveType.NONE
                        count += 1
                        Delay(time, remove_freeze, (play, ))
                        es.emitsound('player', play.userid, 'wcs/root.wav',
                                     1.0, 0.6)
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/laser.vmt "%s,%s,%s" "%s,%s,%s" 10 1 5 5 10 4 0 160 0 155 2'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/laser.vmt "%s,%s,%s" "%s,%s,%s" 10 1 4 4 10 2 0 108 0 180 2'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect_06 #a 0 sprites/laser.vmt "%s,%s,%s" "%s,%s,%s" 10 1 5 5 10 4 0 80 0 190 2'
                            %
                            (atk_origin[0], atk_origin[1], atk_origin[2] + 35,
                             vic_origin[0], vic_origin[1], vic_origin[2] + 35))
                        queue_command_string(
                            'es est_effect 10 #a 0 sprites/laser.vmt %s %s %s 60 20 1 3 3 5 0 80 0 155 0 255 2'
                            %
                            (vic_origin[0], vic_origin[1], vic_origin[2] + 10))
                        queue_command_string(
                            'es est_effect 10 #a 0 sprites/laser.vmt %s %s %s 75 35 1 3 3 6 0 108 0 190 0 255 2'
                            %
                            (vic_origin[0], vic_origin[1], vic_origin[2] + 25))
                    else:
                        es.tell(
                            player.userid, '#multi',
                            '#lightgreenYour ultimate was blocked, the enemy is #greenimmune.'
                        )
                        es.tell(
                            play.userid, '#multi',
                            '#lightgreenYou #greenblocked #lightgreenan ultimate skill.'
                        )
    if count > 0:
        es.centertell(userid, 'Entangling Roots: %s' % (count))
    else:
        es.tell(
            userid, '#multi',
            '#lightgreenEntangling Roots #greenfailed#lightgreen, because no enemy is close enough.'
        )
        cancel(userid, 'player_ultimate')
Пример #19
0
 def players_quantity(self):
     sdm_logger.info(f"connected players: {len(PlayerIter('human'))}")
     # TODO: prevent connecting more than we want (check on_player_connect) and provide reconnect
     if len(PlayerIter('human')) >= self.players_to_start_sdm:# Server maximum clients for round
         authorized_clients = list()
         for player in PlayerIter('human'):
             sdm_logger.debug(f'Checking player {player.index} whose nickname is {player.name}')
             backend_approved = sdm_api.request_server_loads(player, hostname=ConVar('hostname').get_string())
             if backend_approved:
                 authorized_clients.append(player.index)
         if len(authorized_clients) >= self.players_to_start_sdm and self.state_warmup:
             sdm_logger.debug('Starting game preparation')
             self.stop()
             sdm_logger.debug(f'Preparing game for player {authorized_clients[0]}')
             self.game_prepare(authorized_clients[0])
         else:
             sdm_logger.debug(f'Number of clients is {len(authorized_clients)} To start we need {self.players_to_start_sdm} and state of warmup is {self.state_warmup}')
Пример #20
0
def exptick():
    for player in PlayerIter():
        steamid = player.steamid
        if steamid == 'BOT':
            steamid = 'BOT_' + player.name.upper()
        if tickoxp.get_int():
            db[steamid]["exp"] += int(tickoxp)
        db[steamid]["left"] = time()
Пример #21
0
def shutdown():
    """
        Schedules the server for shutdown by setting the TTL to 0
    """
    set_attribute("ttl", 0)

    for player in PlayerIter('human'):
        player.kick("Reservation ended. Thanks for playing!")
Пример #22
0
def alert(message):
    """
        Alerts all players on the server with a message
    """
    print(f"Server Alert: {message}")
    SayText2(f"{ORANGE}Server Alert{WHITE}: {message}").send()
    for player in PlayerIter('human'):
        player.play_sound("ui/system_message_alert.wav")
Пример #23
0
def round_end(ev):
    for user in repeat_dict:
        if valid_repeat(repeat_dict[user]):
            repeat_dict[user].stop()
            repeat_dict[user] = 0
    for player in PlayerIter('all'):
        for weapon in weapon_list:
            wcsgroup.setUser(player.userid, 'resist_' + weapon, 0.0)
Пример #24
0
def _centermessage_command(command):
    message = command.arg_string
    for player in PlayerIter():
        if SOURCE_ENGINE_BRANCH == "css":
            queue_command_string("es_centertell %s %s" %
                                 (player.userid, message))
        else:
            HudMsg(message, -1, 0.35, hold_time=5.0).send(player.index)
Пример #25
0
 def _by_name(self, argument):
     """Returns a list of players by their name"""
     players = {player.name: player for player in PlayerIter()}
     ## Fuzzywuzzy is used to trace a name to a player.
     name, percent = process.extractOne(argument, players.keys())
     if percent <= 60:
         return
     self._add_player(players[name])
Пример #26
0
    def on_team_restriction_added(self, team, weapon):
        """Notify the handler of each player on the restricted team.

        :param int team: The team that just had a restriction added.
        :param str weapon: The weapon that was just restricted.
        """
        for player in PlayerIter(teams_by_number[team]):
            self.on_player_restriction_added(player, weapon)
Пример #27
0
def get_nearby_players(p_vector, radius, is_filters=None, not_filters=None):
    """Gets a list of players near a vector, sorted by distance."""
    players = {}
    for index in PlayerIter(is_filters, not_filters):
        player = PlayerEntity(index)
        distance = p_vector.get_distance(player.get_origin())
        if distance <= radius:
            players[distance] = player
    return sorted(players)
Пример #28
0
 def spectators(self):
     """Return all players observing this player.
     :return: The generator yields :class:`players.entity.Player` objects.
     :rtype: generator
     """
     from filters.players import PlayerIter
     for other in PlayerIter('dead'):
         if self.inthandle == other.observer_target:
             yield other
Пример #29
0
def on_player_iter(command_info):
    log("PyPUG Player List (Iterator):")
    player_iter = PlayerIter.iterator()
    while True:
        try:
            p = player_iter.next()
            log(str(p))
        except Exception as e:
            return
Пример #30
0
def _disconnect_bots():
    """Disconnect all bots."""

    # Cyclic import...
    from filters.players import PlayerIter

    # Notify OnClientDisconnect listener for all bots...
    for bot in PlayerIter('bot'):
        on_client_disconnect_listener_manager.notify(bot.index)
Пример #31
0
    def __init__(self, files, callback, downloadables=None, time_multiplier=1.5, size=0):
        """Initialize the downloader.

        :param tuple files:
            The files to be sent.
        :param callback:
            A callable object to be called after all transfers are complete.
        :param Downloadables downloadables:
            The downloadables to allow new players to download files.
        :param float time_multiplier:
            The multiplier for the wait time to stop the downloader.
        :param int size:
            Total compressed file size to skip compression.
        """

        global transfer_id

        self.files = files
        self.callback = callback
        self.downloadables = downloadables
        self.size = size

        self.file = self.files[-1].encode("utf-8")

        if self.size:
            if self.downloadables is not None:
                for file in files:
                    self.downloadables.add(file)
        else:
            compress = net_compresspackets.get_bool()
            for file in files:
                path = Path(GAME_PATH / file)
                self.size += compress_file(path) if compress else path.stat().st_size
                if self.downloadables is not None:
                    self.downloadables.add(file)

        self.estimated_time  = (self.size/256)*server.tick_interval
        self.transfer_time = self.estimated_time
        self.time_limit = self.estimated_time*time_multiplier

        self.success = list()
        self.failed = list()
        self.receivers = dict()

        for player in PlayerIter("human"):
            net_channel = player.client.net_channel
            for file in self.files:
                if not net_channel.send_file(file, transfer_id):
                    self.failed.append(player.index)
                    break
                transfer_id += 1
            else:
                self.receivers[player.index] = ctypes.c_void_p(net_channel._ptr().address)

        Delay(self.estimated_time, self.transfer_end, cancel_on_level_end=True)

        self._downloader[id(self)] = self
    def iterator():
        seen_steamids = []
        result = []
        for player in PlayerIter.iterator():
            seen_steamids.append(player.steamid)
            result.append(LeftPlayer(player.index, disconnected=False))

        for left_player in _left_players:
            if left_player.steamid in seen_steamids:
                continue

            result.insert(0, left_player)

        yield from result
Пример #33
0
def on_load():
    is_rebel = lambda player: player in _rebels
    PlayerIter.register_filter('jail_rebel', is_rebel)
Пример #34
0
def on_load():
    PlayerIter.register_filter(
        'jail_prisoner', lambda player: player.team == PRISONERS_TEAM)

    PlayerIter.register_filter(
        'jail_guard', lambda player: player.team == GUARDS_TEAM)
Пример #35
0
def on_unload():
    PlayerIter.unregister_filter('jail_rebel')
Пример #36
0
def on_unload():
    PlayerIter.unregister_filter('jail_prisoner')
    PlayerIter.unregister_filter('jail_guard')