def saycommand_bet(playerinfo, teamonly, command):
    global bets
    player = PlayerEntity(index_from_playerinfo(playerinfo))

    params = str(command[1]).split(" ")

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

        team_number = player.team
#        team_number = 1 # For Testing

        # Check if player is spectator
        if team_number == 1:

            if int(amount) >= 100:
                if team == "t":
                    SayText2(message="PAYOUT - " + amount + " SAT - T WIN").send(index_from_playerinfo(playerinfo))
                    leetcoin_client.requestAward(-int(amount), "PAYOUT - " + amount + " SAT - T WIN", userid_from_playerinfo(playerinfo))
                    bets['t'][userid_from_playerinfo(playerinfo)] = int(amount)
                if team == "ct":
                    SayText2(message="PAYOUT - " + amount + " SAT - CT WIN").send(index_from_playerinfo(playerinfo))
                    leetcoin_client.requestAward(-int(amount), "PAYOUT - " + amount + " SAT - CT WIN", userid_from_playerinfo(playerinfo))
                    bets['ct'][userid_from_playerinfo(playerinfo)] = int(amount)
            else:
                SayText2(message="Minimum bet is 100 SAT").send(index_from_playerinfo(playerinfo))
        else:
            SayText2(message="Only spectators can bet").send(index_from_playerinfo(playerinfo))
    else:
        SayText2(message="Type: bet <team> <amount>").send(index_from_playerinfo(playerinfo))
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
Пример #3
0
 def slay(cls, player, **kwargs):
     """Slay a player"""
     if not player.dead:
         player.slay()
         SayText2(messages['Slay']).send(player.index)
     else:
         SayText2(messages['Already Dead']).send(kwargs['owner'])
Пример #4
0
 def mute(cls, player, *args):
     """Mute a player"""
     if player.is_muted():
         player.unmute()
         SayText2(messages['Unmute']).send(player.index)
     else:
         player.mute()
         SayText2(messages['Mute']).send(player.index)
Пример #5
0
def make_player_notready(command, index, team):
    key = Player(index).index
    current_player = players[key]

    if current_player.is_ready:
        current_player.is_ready = False
        SayText2(CHAT_PREFIX + "You have been marked as \x02NOT READY").send(index)
    elif not current_player.is_ready:
        SayText2(CHAT_PREFIX + "You're already \x02NOT READY").send(index)
Пример #6
0
def _resetscrore_say_command(command, index, team_only=None):
    player = Player(index)
    if player.kills != 0 or player.deaths != 0: 
        player.kills = 0
        player.deaths = 0
        SayText2(strings['Resetscore']).send(player.index)
    else:
        SayText2(strings['Already']).send(player.index)

    return CommandReturn.BLOCK
Пример #7
0
def make_player_ready(command, index, team):
    key = Player(index).index
    current_player = players[key]

    if not current_player.is_ready:
        current_player.is_ready = True
        SayText2(CHAT_PREFIX + "You have been marked as \x06READY").send(index)
        try_start_match(index)
    elif current_player.is_ready:
        SayText2(CHAT_PREFIX + "You're already \x06READY").send(index)
Пример #8
0
def addGold(userid, amount, reason=''):
    player = Player.from_userid(userid)
    pickle.keySetValue(
        player.steamid, 'gold',
        int(pickle.keyGetValue(player.steamid, 'gold')) + int(amount))
    if not reason:
        SayText2('\x04[WCS] \x05You have gained \x04%s Gold.' % amount).send(
            player.index)
    else:
        SayText2('\x04[WCS] \x05You have gained \x04%s Gold %s' %
                 (amount, reason)).send(player.index)
Пример #9
0
def on_se_chat_message(msg, _):
    if isinstance(msg, MessagePosted) and msg.user.id != me:
        content = unescape(msg.content)

        if content.startswith("!"):
            command_dispatch(content.split(" ", 1), msg.user)
            if announce_se_commands:
                SayText2("\x07" + se_color + "[SE] " + msg.user.name +
                         "\x01: " + content).send()
        else:
            SayText2("\x07" + se_color + "[SE] " + msg.user.name + "\x01: " +
                     content).send()
Пример #10
0
def takeGold(userid, amount, reason=''):
    player = Player.from_userid(userid)
    gold = pickle.keyGetValue(player.steamid, 'gold')
    to_set = gold - amount
    if to_set < 0:
        to_set = 0
    pickle.keySetValue(player.steamid, 'gold', to_set)
    if not reason:
        SayText2('\x04[WCS] \x05You have lost \x04%s Gold.' % amount).send(
            player.index)
    else:
        SayText2('\x04[WCS] \x05You have lost \x04%s Gold %s' %
                 (amount, reason)).send(player.index)
Пример #11
0
def say_df(command, index, team_only):
    if not config_manager['allow_drop_flag_command']:
        SayText2(tagged(colorize(common_strings['disabled']))).send(index)
        return

    ctfplayer = ctfplayers[index]
    for flag in _flags.values():
        if flag.ctfplayer is not None and flag.ctfplayer == ctfplayer:
            ctfplayer.dropped_flag_at = time()
            flag.drop()
            break

    else:
        SayText2(tagged(colorize(
            common_strings['no_flag_on_you']))).send(index)
Пример #12
0
    def tell(userid, text, tokens={}, extra='', lng=True):
        players, message = _format_message(
            str(userid), text, ' '.join(f'{x} {y}' for x, y in tokens.items()))

        for player in players:
            SayText2(message[message.get(player.language,
                                         'en')]).send(player.index)
Пример #13
0
def on_event(game_event):
    userid = game_event.get_int("userid")
    index = index_from_userid(userid)
    player = Player(index)
    reason = game_event.get_string("reason")
    SayText2("%s {0} %shas left. Reason: \"%s{1}%s\"".format(player.name, reason) % (Color(0,153,0), Color(255,255,51), Color(255,255,255), Color(255,255,51))).send()
    return CommandReturn.BLOCK
Пример #14
0
    def on_data_received(self, data):
        if data['action'] == "chat-message":
            SayText2("{} through MOTD: '{}'".format(self.player_name,
                                                    data['message'])).send()

        else:
            log_console("Error! Unexpected action: {}".format(data['action']))
Пример #15
0
        def method_wrapper(self, **eargs):

            # If the method's cooldown is over
            if method_wrapper.cooldown.remaining <= 0:

                # Restart the cooldown
                method_wrapper.cooldown.start(1, fn(self, **eargs))

                # And call the function
                return method(self, **eargs)

            # If there was cooldown remaining and a message is provided
            if message:

                # Format the provided message
                formatted_message = message.format(
                    name=self.name,
                    cd=method_wrapper.cooldown.remaining,
                    max_cd=method_wrapper.cooldown.limit)

                # And send it to the player
                SayText2(message=formatted_message).send(eargs['player'].index)

                # And exit with code 3
                return 3
def round_start(game_event):
    print("Round Start")

    players = PlayerIter('human')
    for player in players:
        SayText2(message="Commands: bet, bounty").send(player)
    pass
    def set_player_team(self, user_id, new_team_id, old_team_id=None):
        if old_team_id in self.teams:
            team = self.teams[old_team_id]
            try:
                team.remove(user_id)
                msg = 'Removed player %s from team %d' % (
                    self.users[user_id]['name'], old_team_id)
                SayText2(msg).send()
            except KeyError as ex:
                msg = 'Failed to remove player %s from team %d: %s' % \
                    (self.users[user_id]['name'], old_team_id, str(ex))
                SayText2(msg).send()

        self.teams[new_team_id].add(user_id)
        msg = 'Added player %s to team %d.' % \
            (self.users[user_id]['name'], old_team_id)
        SayText2(msg).send()
Пример #18
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")
Пример #19
0
def expshop_menu_select(menu, index, choice):
    player = Player(index)
    if player.cash >= int(choice.value[1]):
        player.cash -= int(choice.value[1])
        queue_command_string('wcs_givexp %s %s' %
                             (player.userid, choice.value[0]))
        if SOURCE_ENGINE_BRANCH == 'css':
            SayText2("\x04[WCS] \x03You bought \x04%s XP \x03for \x04%s$." %
                     (choice.value[0], choice.value[1])).send(index)
        else:
            SayText2("\x04[WCS] \x05You bought \x04%s XP \x05for \x04%s$." %
                     (choice.value[0], choice.value[1])).send(index)
    else:
        if SOURCE_ENGINE_BRANCH == 'css':
            SayText2("\x04[WCS] \x03You don't have enough cash.").send(index)
        else:
            SayText2("\x04[WCS] \x05You don't have enough cash.").send(index)
Пример #20
0
def rule_menu_callback(_menu, _index, _option):
	choice = _option.value
	if choice:
		userid = userid_from_index(_index)        
		if choice == 'No':
			queue_command_string('kickid %s You have to accept the rules!' % (userid))
		elif choice == 'Yes':
			SayText2('\x04Thank you for accepting the rules and have fun!').send(_index)
Пример #21
0
def respawn_bots(game_event):
        userid = game_event.get_int("userid")
        index = index_from_userid(userid)
        player = Player(index)
        playerinfo = playerinfo_from_index(index)
        if playerinfo.is_fake_client():
            SayText2("Respawning {0}".format(player.name)).send()
            Delay(2, player=Player(index))
            player.respawn()
Пример #22
0
def sql_callback_3(get_info):
    """
    get_info includes 'query', 'time', 'prioritized'
    """
    query = get_info['query']
    time = get_info['time']
    prio = get_info['prioritized']
    SayText2('Query: {0}\nTime: {1} seconds\nPrioritized: {2}'.format(
        query, time, prio)).send()
Пример #23
0
def on_extend(command_info):
    if get_remaining_time() > 30*60:
        remaining = readable_time(get_remaining_time())
        SayText2(f"Reservation can only be extended with <{ORANGE}30 {WHITE}minutes remaining. Time remaining: {ORANGE}{remaining}").send()
        return
    else:
        extend_time(60)
        remaining = readable_time(get_remaining_time())
        alert(f"Reservation been extended by {ORANGE}1 hour{WHITE}. Time remaining: {ORANGE}{remaining}")
Пример #24
0
def victory(team):
    message = common_strings['team victory ' + team.name.lower()]
    SayText2(tagged(colorize(message))).send()

    for team in _team_points.keys():
        _team_points[team] = 0

    info_map_parameters = Entity.find_or_create('info_map_parameters')
    info_map_parameters.fire_win_condition(
        WIN_CONDITIONS.get(team.value, WIN_CONDITIONS[0]))
Пример #25
0
def _gold_admin_menu_select(menu, index, choice):
    userid = userid_from_index(index)
    if choice.choice_index == 1:
        if has_flag(userid, 'goldadmin_givegold'):
            giveGolddoCommand(userid)
        else:
            SayText2('\x04[WCS] \x05You do not have  \x04access \x05this menu!'
                     ).send(index)
            gold_admin_menu.send(index)
    if choice.choice_index == 2:
        if has_flag(userid, 'goldadmin_removegold'):
            takeGolddoCommand(userid)
        else:
            SayText2('\x04[WCS] \x05You do not have \x04access \x05this menu!'
                     ).send(index)
            gold_admin_menu.send(index)

    if choice.choice_index == 9:
        menu.close(index)
Пример #26
0
def list_players(command, index, team):
    all_players = []
    for key, value in players.items():
        ready_status = value.is_ready
        if ready_status is True:
            player_ready = "READY"
        elif ready_status is False:
            player_ready = "NOT READY"
        all_players.append(value.username + " : " + player_ready + ", ")
    SayText2(CHAT_PREFIX + str(all_players)).send(index)
Пример #27
0
def on_command(command, index, team_only):
     player = Player(index)
     player.health -= 5
     try:
         command[1]
     except IndexError:
         cut_with = "knife"
     else:
         cut_with = command[1] 
     SayText2("{0} has cut themself with {1}".format(player.name, cut_with)).send()
     return CommandReturn.BLOCK
Пример #28
0
 def select(menu, index, choice):
     """Change map"""
     Delay(3, engine_server.change_level, (
         choice.value,
         None,
     ))
     for player in PlayerIter('human'):
         SayText2(messages['Change Map'].get_string(player.language[:2],
                                                    name=choice.value,
                                                    duration=3)).send()
     return menu
    def remove_player(self, user_id):
        del self.users[user_id]

        for team_id, team in self.teams.items():
            try:
                team.remove(user_id)
                msg = 'Removed player %s from team %d' % (
                    self.users[user_id]['name'], team_id)
                SayText2(msg).send()
            except KeyError:
                pass
Пример #30
0
def get_messages(lang_strings):
    """Gets a dict of SayText2 messages from a LangStrings object.

    Args:
        lang_strings: LangStrings object used to fetch the messages

    Returns:
        A dict of SayText2 messages
    """

    return {key: SayText2(message=lang_strings[key]) for key in lang_strings}