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
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
Exemplo n.º 3
0
 def command_callback(self, command, player=None, teamonly=None):
     if teamonly is not None:
         command = SayCommandProxy(command)
         silent = True if command.args[0].startswith("/") else False
         command.args[0] = command.args[0][1:]
         self.callback(CommandSourceProxy("say", index_from_playerinfo(player)), command)
         return CommandReturn.BLOCK if silent else CommandReturn.CONTINUE
     elif player is not None:
         return self.callback(CommandSourceProxy("console", index_from_playerinfo(player)), command)
     else:
         return self.callback(CommandSourceProxy("server"), command)
def send_balance():
    promo = leetcoin_client.isPromo()
    increment = leetcoin_client.getIncrementBTC()
    if promo:
        increment = 0
    amount = amount_to_pay()
    for player in PlayerIter(['human', 'alive'], return_types='playerinfo'):
        balance = leetcoin_client.getPlayerBalance(convertSteamIDToCommunityID(player.get_networkid_string()))
        mes = "Round Buy in: -" + leetcoin_client.getConvertedAmountValue(convertSteamIDToCommunityID(player.get_networkid_string()), increment)
        mes2 = "Updated " + balance + "" # balance
        mes3 = "Last one to survive wins the pot! (+" + leetcoin_client.getConvertedAmountValue(convertSteamIDToCommunityID(player.get_networkid_string()), amount) + " )" # amount
        SayText2(message="" + mes + "").send(index_from_playerinfo(player))
        SayText2(message="" + mes2 + "").send(index_from_playerinfo(player))
        SayText2(message="" + mes3 + "").send(index_from_playerinfo(player))
Exemplo n.º 5
0
def _get_valid_attacker(game_event):
    """Return the attacker's userid if not a self or team inflicted event."""
    # Get the attacker's userid
    attacker = game_event.get_int('attacker')

    # Get the victim's userid
    victim = game_event.get_int('userid')

    # Was this self inflicted?
    if attacker in (victim, 0):

        # If self, inflicted, do not count
        return None

    # Get the victim's PlayerInfo instance
    vplayer = playerinfo_from_userid(victim)

    # Get the attacker's PlayerInfo instance
    aplayer = playerinfo_from_userid(attacker)

    # Are the player's on the same team?
    if vplayer.get_team_index() == aplayer.get_team_index():

        # Do not count
        return index_from_playerinfo(aplayer)

    # If all checks pass, count the attack/kill
    return player_dictionary[attacker]
Exemplo n.º 6
0
def client_command_ultimate(playerinfo, command):
    """Raises ultimate event with player's information."""

    Player_Ultimate(
        index=index_from_playerinfo(playerinfo),
        userid=userid_from_playerinfo(playerinfo)
    ).fire()
def player_death(game_event):
    """ this includes bots apparently """
    print("Player Death")
    # Get the userid from the event
    victim = game_event.get_int('userid')
    attacker = game_event.get_int('attacker')
    print("victim: %s" % victim)
    print("attacker: %s" % attacker)
    
    #victim_edict = edict_from_userid(victim)
    #attacker_edict = edict_from_userid(attacker)
    #print("victim_edict: %s" % victim_edict)
    #print("attacker_edict: %s" % attacker_edict)
    
    # Get the CPlayerInfo instance from the userid
    victimplayerinfo = playerinfo_from_userid(victim)
    attackerplayerinfo = playerinfo_from_userid(attacker)
    print("victimplayerinfo: %s" % victimplayerinfo)
    print("attackerplayerinfo: %s" % attackerplayerinfo)
    # And finally get the player's name 
    #victimname = victimplayerinfo.get_name()
    #attackername = attackerplayerinfo.get_name()
    #print("victimname: %s" % victimname)
    #print("attackername: %s" % attackername)
    
    # Get the index of the player
    victimindex = index_from_userid(victim)
    attackerindex = index_from_userid(attacker)
    print("victimindex: %s" % victimindex)
    print("attackerindex: %s" % attackerindex)
    
    print("victim_is_fake_client: %s" % victimplayerinfo.is_fake_client())
    print("attacker_is_fake_client: %s" % attackerplayerinfo.is_fake_client())
    
    victim_steamid = victimplayerinfo.get_networkid_string()
    attacker_steamid = attackerplayerinfo.get_networkid_string()
    
    if not victimplayerinfo.is_fake_client() and not attackerplayerinfo.is_fake_client():
        count = alive_count()
        global round_count
        global round_won
        if count == 1 and round_count != 1: 
            userid = winning_player()
            amount = amount_to_pay()
            name = playerinfo_from_userid(userid).get_name()
            award = leetcoin_client.requestAward(amount, "Hunger Games Winner", userid)
            tell_winner(winning_playerinfo())
            for player in PlayerIter(['human'], return_types='playerinfo'):
                mes = name + " survived and won " + leetcoin_client.getConvertedAmountValue(convertSteamIDToCommunityID(player.get_networkid_string()), amount)
                SayText2(message="" + mes + "").send(index_from_playerinfo(player))
            print("Winner selected, userid: " + str(userid))
            round_won = True
            #leetcoin_client.submit_match_results_blank()
        else:
            print("Alive count at: " + str(count))


    return
Exemplo n.º 8
0
def client_command_menu(playerinfo, command):
    """Opens a menu."""

    index = index_from_playerinfo(playerinfo)
    menu = command.get_arg_string()
    if menu in menus:
        menus[menu].send(index)
    else:
        menus['Main'].send(index)
Exemplo n.º 9
0
def client_command_menu(playerinfo, command):
    """Opens a menu."""

    index = index_from_playerinfo(playerinfo)
    if command == 'hw_menu':
        menus['main'].send(index)
    else:
        _, menu = command.split(maxsplit=1)
        if menu in menus:
            menus[menu].send(index)
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_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 check_for_winner():
    count = alive_count()
    global round_count
    global round_won
    if count == 1 and round_count != 1 and not round_won: 
        userid = winning_player()
        amount = amount_to_pay()
        name = playerinfo_from_userid(userid).get_name()
        award = leetcoin_client.requestAward(amount, "Hunger Games Winner", userid)
        tell_winner(winning_playerinfo())
        for player in PlayerIter(['human'], return_types='playerinfo'):
            mes = name + " survived and won " + leetcoin_client.getConvertedAmountValue(convertSteamIDToCommunityID(player.get_networkid_string()), amount)
            SayText2(message="" + mes + "").send(index_from_playerinfo(player))
        print("Winner selected, userid: " + str(userid))
    else:
        print("Alive count at: " + str(count))
Exemplo n.º 13
0
def _validate_selection(player_info, command, valid_choices):
    """Validate a selection command.

    @param <player_infor>:
    A PlayerInfo instance.

    @param <command>:
    A Command instance.

    @param <valid_choices>:
    A list of integers that defines all valid choices
    """
    try:
        choice = int(command.get_arg(1))
    except ValueError:
        # Catch errors caused by e.g. "menuselect a"
        return (None, None)

    if choice in valid_choices:
        return (index_from_playerinfo(player_info), choice)

    return (None, None)
def saycommand_test(playerinfo, teamonly, command):
    #SayText2(message="balance").send(index_from_playerinfo(playerinfo))
    balance = leetcoin_client.getPlayerBalance(convertSteamIDToCommunityID(playerinfo.get_networkid_string()))
    SayText2(message="" + balance + "").send(index_from_playerinfo(playerinfo))
def saycommand_test(playerinfo, teamonly, command):
    #SayText2(message="balance").send(index_from_playerinfo(playerinfo))
    balance = leetcoin_client.getPlayerBalance(convertSteamIDToCommunityID(playerinfo.get_networkid_string()))
    SayText2(message="" + balance + "").send(index_from_playerinfo(playerinfo))
def round_end(game_event):
    print(">>>>>>>>>>>>>>>>>>>  Round End")
    # award winners
    global bets
    winner = game_event.get_int("winner")

    # Check both teams have bets
    if not bets['ct'] or not bets['t']:
        # Refund bets
        for userid, amount in bets['ct'].items():
            SayText2(message="REFUND - " + str(amount) + " SAT - NOT ENOUGH BETS").send(index_from_userid(userid))
            leetcoin_client.requestAward(amount, "REFUND - " + str(amount) + " SAT - NOT ENOUGH BETS", userid)
        for userid, amount in bets['t'].items():
            SayText2(message="REFUND - " + str(amount) + " SAT - NOT ENOUGH BETS").send(index_from_userid(userid))
            leetcoin_client.requestAward(amount, "REFUND - " + str(amount) + " SAT - NOT ENOUGH BETS", userid)
        pass
    else:
        # Calculate pool
        pool_ct = 0
        pool_t = 0
        for userid, amount in bets['ct'].items():
            pool_ct += amount
        for userid, amount in bets['t'].items():
            pool_t += amount
        pool = pool_ct + pool_t

        # 10% for players
        player_cut = pool * 0.1
        remaining = pool - player_cut

        if winner == 2:
            print("T Wins!")
            for userid, amount in bets['t'].items():
                award = remaining / (amount / pool_t)
                leetcoin_client.requestAward(award, "Won bet on T", userid)
                playerinfo = playerinfo_from_userid(userid)
                SayText2(message="You won " + str(award) + " Satoshi").send(index_from_playerinfo(playerinfo))

            if not bets['t']:
                pass
            else:
                # Pay players
                players = PlayerIter('t', 'bot', 'userid')
                for player in players:
                    kickback = player_cut / len(players)
                    leetcoin_client.requestAward(math.ceil(kickback), "Player on winning team", player)
        if winner == 3:
            print("CT Wins!")
            # Pay winners
            for userid, amount in bets['ct'].items():
                award = remaining / (amount / pool_ct)
                leetcoin_client.requestAward(award, "Won bet on CT", userid)
                playerinfo = playerinfo_from_userid(userid)
                SayText2(message="You won " + str(award) + "Satoshi").send(index_from_playerinfo(playerinfo))

            if not bets['ct']:
                pass
            else:
                # Pay players
                players = PlayerIter('ct', 'bot', 'userid')
                for player in players:
                    kickback = player_cut / len(players)
                    leetcoin_client.requestAward(math.ceil(kickback), "Player on winning team", player)
                
    leetcoin_client.repeatingServerUpdate()
    bets = {'ct': {}, 't': {}}
    pass   
Exemplo n.º 17
0
 def _send_menu(self, playerinfo, *args):
     """Send the main settings menu to the player who requested it."""
     self.menu.send(index_from_playerinfo(playerinfo))
def tell_winner(playerinfo):
    amount = amount_to_pay()
    balance = leetcoin_client.getPlayerBalance(convertSteamIDToCommunityID(playerinfo.get_networkid_string()))
    mes = "You won " + leetcoin_client.getConvertedAmountValue(convertSteamIDToCommunityID(playerinfo.get_networkid_string()), amount)
    #mes2 = "Updated " + balance
    SayText2(message="" + mes + "").send(index_from_playerinfo(playerinfo))
Exemplo n.º 19
0
def _return_language(CPlayerInfo):
    '''Returns the player's language'''
    return GameEngine.get_client_convar_value(
        index_from_playerinfo(CPlayerInfo), 'cl_language')
Exemplo n.º 20
0
def _return_player(CPlayerInfo):
    '''Returns the player's PlayerEntity instance'''
    return PlayerEntity(index_from_playerinfo(CPlayerInfo))
Exemplo n.º 21
0
def _return_language(PlayerInfo):
    '''Returns the player's language'''
    return EngineServer.get_client_convar_value(
        index_from_playerinfo(PlayerInfo), 'cl_language')
def tell_all_players(mes):
    for player in PlayerIter(['human'], return_types='playerinfo'):
        SayText2(message="" + mes + "").send(index_from_playerinfo(player))
Exemplo n.º 23
0
def client_command_ultimate(playerinfo, command):
    """Raises ultimate event with player's information."""

    Player_Ultimate(index=index_from_playerinfo(playerinfo),
                    userid=userid_from_playerinfo(playerinfo)).fire()