def gg_start(event_var):
    global played_knife
    global played_nade
    global knife_level
    global nade_level

    # Reset the globals when GG starts
    played_knife = False
    played_nade = False
    nade_level = 0
    knife_level = 0

    # Loop through all levels
    for level in xrange(1, get_total_levels() + 1):

        # Get the weapon for the current level
        weapon = get_level_weapon(level)

        # Is the weapon hegrenade?
        if weapon == 'hegrenade':

            # Each time hegrenade is found, change nade_level so
            # that nade_level ends up being the last hegrenade level
            nade_level = level

        # Is the weapon knife?
        if weapon == 'knife':

            # Each time knife is found, change knife_level so
            # that knife_level ends up being the last knife level
            knife_level = level
Example #2
0
    def check_final_kill(self, userid, weapon):
        '''Checks to see if the kill should end the match'''

        # Is the team on the last level?
        if self.level != get_total_levels():

            # If not, return
            return

        # Is the team on the last multikill for the last level?
        if self.multikill + 1 < get_level_multikill(self.level):

            # If not, return
            return

        # Was the weapon used the last level's weapon?
        if get_level_weapon(self.level) != weapon:

            # If not, return
            return

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the attacker on the last level?
        if ggPlayer.level != get_total_levels():

            # If not, return
            return

        # End the match
        GG_Team_Win(winner=self.team, loser=5 - self.team).fire()
Example #3
0
def weapons_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    weaponOrder = []
    level = 1
    totalLevels = get_total_levels()

    while level <= totalLevels:
        weaponOrder.append(
            "[%s] %s" % (get_level_multikill(level), get_level_weapon(level)))
        level += 1

    # Get the level the player is on
    ggLevel = Player(userid).level

    # Create a new OrderedMenu
    ggWeaponsMenu = OrderedMenu(userid,
                                'GunGame: Weapons Menu',
                                weaponOrder,
                                highlightIndex=ggLevel)

    # Send the OrderedMenu on the page the player's weapon is on
    ggWeaponsMenu.send_page(get_index_page(ggLevel))
Example #4
0
def get_weapon(userid):
    # Using a weapon list ?
    if using_weapon_list():
        return [
            get_level_weapon(
                Player(userid).nadeBonusLevel, str(gg_nade_bonus))
        ]

    # Getting regular weapon(s)
    weap = str(gg_nade_bonus).split(',')

    # Cleaning up list
    for index in range(len(weap)):

        # We know the first one is clean
        if index == 0:
            continue

        # Removing spaces
        weap[index] = str(weap[index]).replace(' ', '')

        # Valid weapon(s)?
        if ('weapon_' + weap[index]) not in list_Weapons:

            # Send error
            raise ValueError('gg_nade_bonus (%s) contains ' % gg_nade_bonus +
                             'the invalid weapon "%s"' % weap[index])

    # Sending weapon(s)
    return weap
Example #5
0
def gg_leveldown(event_var):
    userid = int(event_var['userid'])

    # Player leveled down to nade ?
    if not check_bonus(userid):
        return

    # Using weapon list ?
    if not using_weapon_list():
        return

    oldlevel = int(event_var['old_level'])

    # Was Player on nade ?
    if get_level_weapon(oldlevel) == 'hegrenade':

        # Reset bonus levels
        Player(userid).nadeBonusMulti = 0
        Player(userid).nadeBonusLevel = 1

    # Giving bonus (delayed more for bots)
    if es.isbot(userid):
        gamethread.delayed(0.50, give_bonus, userid)
        return

    gamethread.delayed(0.10, give_bonus, userid)
Example #6
0
    def check_final_kill(self, userid, weapon):
        '''Checks to see if the kill should end the match'''

        # Is the team on the last level?
        if self.level != get_total_levels():

            # If not, return
            return

        # Is the team on the last multikill for the last level?
        if self.multikill + 1 < get_level_multikill(self.level):

            # If not, return
            return

        # Was the weapon used the last level's weapon?
        if get_level_weapon(self.level) != weapon:

            # If not, return
            return

        # Get the Player instance
        ggPlayer = Player(userid)

        # Is the attacker on the last level?
        if ggPlayer.level != get_total_levels():

            # If not, return
            return

        # End the match
        GG_Team_Win(winner=self.team, loser=5 - self.team).fire()
Example #7
0
def gg_leveldown(event_var):
    userid = int(event_var['userid'])

    # Player leveled down to nade ?
    if not check_bonus(userid):
        return

    # Using weapon list ?
    if not using_weapon_list():
        return

    oldlevel = int(event_var['old_level'])

    # Was Player on nade ?
    if get_level_weapon(oldlevel) == 'hegrenade':

        # Reset bonus levels
        Player(userid).nadeBonusMulti = 0
        Player(userid).nadeBonusLevel = 1

    # Giving bonus (delayed more for bots)
    if es.isbot(userid):
        gamethread.delayed(0.50, give_bonus, userid)
        return

    gamethread.delayed(0.10, give_bonus, userid)
Example #8
0
def get_weapon(userid):
    # Using a weapon list ?
    if using_weapon_list():
        return [get_level_weapon(Player(userid).nadeBonusLevel,
                                                str(gg_nade_bonus))]

    # Getting regular weapon(s)
    weap = str(gg_nade_bonus).split(',')

    # Cleaning up list
    for index in range(len(weap)):

        # We know the first one is clean
        if index == 0:
            continue

        # Removing spaces
        weap[index] = str(weap[index]).replace(' ', '')

        # Valid weapon(s)?
        if ('weapon_' + weap[index]) not in list_Weapons:

            # Send error
            raise ValueError('gg_nade_bonus (%s) contains ' % gg_nade_bonus +
                'the invalid weapon "%s"' % weap[index])

    # Sending weapon(s)
    return weap
Example #9
0
def leader_menu_cmd(userid, args):
    global leaderList

    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    # Get menu contents
    newLeaderList = ['->1. Current Leaders:']
    leaderNames = get_leader_names()

    # Add names if we have leaders
    if leaderNames:
        # Add leader level and weapon
        leaderLevel = get_leader_level()
        newLeaderList.append('    Level %s (%s)' % (leaderLevel,
                                get_level_weapon(leaderLevel)))

        # Divider
        newLeaderList.append('-' * 26)

        # Add player names
        for player_name in leaderNames:
            newLeaderList.append('   * %s' % player_name)

    # No leader
    else:
        newLeaderList.extend(('-' * 26, '   * There currently is no leader'))

    # Finish popup with divider and exit
    newLeaderList.extend(('-' * 26, '0. Exit'))

    # Does the popup exists ?
    if popuplib.exists('ggLeaderMenu'):

        # Send the user the current popup ?
        if newLeaderList == leaderList:
            popuplib.send('ggLeaderMenu', userid)
            return

        # Delete the popup
        popuplib.unsendname('ggLeaderMenu', getUseridList('#human'))
        popuplib.delete('ggLeaderMenu')

    # Build new popup
    ggLeaderMenu = popuplib.create('ggLeaderMenu')
    ggLeaderMenu.timeout('send', 10)
    ggLeaderMenu.timeout('view', 10)

    # Add lines to new popup
    for line in newLeaderList:
        ggLeaderMenu.addline(line)

    # Save current popup
    leaderList = newLeaderList

    # Send it
    popuplib.send('ggLeaderMenu', userid)
Example #10
0
def player_death(event_var):
    # Get the userids of the attacker and victim
    attacker = int(event_var['attacker'])
    userid = int(event_var['userid'])

    # If there is no attacker (falling to death), return
    if not attacker:
        return

    # If the kill was a suicide, return
    if attacker == userid:
        return

    # If the kill was a teamkill, return
    if event_var['es_attackerteam'] == event_var['es_userteam']:
        return

    # Get the name of the weapon used to get the kill
    weapon = event_var['weapon']

    ggPlayer = Player(attacker)
    level = ggPlayer.level

    # If the player has already leveled up internally, check their last level
    if attacker in recentlyLeveled:
        level -= 1
        level = 1 if level < 1 else level

    reloadWeapons = [get_level_weapon(level)]
    # If nade bonus is loaded, add the bonus weapons to reloadWeapons
    if not str(gg_nade_bonus) in ('', '0'):
        reloadWeapons.extend(get_weapon(userid))

    # If the weapon name doesn't match the player's level's weapon name at the
    # time, return
    if not weapon in reloadWeapons:
        return

    # If the player is on hegrenade or knife level, return
    if weapon in ('hegrenade', 'knife'):
        return

    # Get the weapon object and the size if its clip
    weaponObject = getWeapon(weapon)

    # Find the attacker's weapon index to be used to reload the weapon
    playerHandle = es.getplayerhandle(attacker)

    for index in weaponObject.indexlist:
        # When the attacker's handle matches the index handle we have found
        # the attacker's weapon index
        if es.getindexprop(index,
                           'CBaseEntity.m_hOwnerEntity') == playerHandle:
            # Set the clip to the maximum ammo allowed
            getPlayer(attacker)['clip'][weaponObject] = weaponObject.clip
            break
Example #11
0
def player_death(event_var):
    # Get the userids of the attacker and victim
    attacker = int(event_var['attacker'])
    userid = int(event_var['userid'])

    # If there is no attacker (falling to death), return
    if not attacker:
        return

    # If the kill was a suicide, return
    if attacker == userid:
        return

    # If the kill was a teamkill, return
    if event_var['es_attackerteam'] == event_var['es_userteam']:
        return

    # Get the name of the weapon used to get the kill
    weapon = event_var['weapon']

    ggPlayer = Player(attacker)
    level = ggPlayer.level

    # If the player has already leveled up internally, check their last level
    if attacker in recentlyLeveled:
        level -= 1
        level = 1 if level < 1 else level

    reloadWeapons = [get_level_weapon(level)]
    # If nade bonus is loaded, add the bonus weapons to reloadWeapons
    if not str(gg_nade_bonus) in ('', '0'):
        reloadWeapons.extend(get_weapon(userid))

    # If the weapon name doesn't match the player's level's weapon name at the
    # time, return
    if not weapon in reloadWeapons:
        return

    # If the player is on hegrenade or knife level, return
    if weapon in ('hegrenade', 'knife'):
        return

    # Get the weapon object and the size if its clip
    weaponObject = getWeapon(weapon)

    # Find the attacker's weapon index to be used to reload the weapon
    playerHandle = es.getplayerhandle(attacker)

    for index in weaponObject.indexlist:
        # When the attacker's handle matches the index handle we have found
        # the attacker's weapon index
        if es.getindexprop(index,
          'CBaseEntity.m_hOwnerEntity') == playerHandle:
            # Set the clip to the maximum ammo allowed
            getPlayer(attacker)['clip'][weaponObject] = weaponObject.clip
            break
def check_leader_warning(level):
    global played_knife
    global played_nade

    # Set sound to False for use later
    sound = False

    # Get the leader's weapon
    weapon = get_level_weapon(level)

    # Is the player on knife level?
    if weapon == 'knife':

        # Has the knifelevel sound been played?
        if played_knife:
            return

        # Does the knifelevel sound always get played
        # or is the leader on the last knife level?
        if not int(warn_last_level_only) or level == knife_level:

            # Set the sound to knifelevel
            sound = 'knifelevel'

            # Set played_knife so it does not get played again this round
            played_knife = True

    # Is the player on hegrenade level?
    if weapon == 'hegrenade':

        # Has the nadelevel sound been played?
        if played_nade:
            return

        # Does the nadelevel sound always get played
        # or is the leader on the last nade level?
        if not int(warn_last_level_only) or level == nade_level:

            # Set the sound to nadelevel
            sound = 'nadelevel'

            # Set played_nade so it does not get played again this round
            played_nade = True

    # Is a sound supposed to be played?
    if not sound:

        # Do not play any sound
        return

    # Loop through all human players
    for userid in getUseridList('#human'):

        # Play the leader level sound
        Player(userid).playsound(sound)
Example #13
0
def level_call_back(name, value, ggPlayer):
    # If the player is getting their level attribute set for the first time, we
    # can't get it yet
    if not hasattr(ggPlayer, "level"):
        return

    # If the player did not level up off of knife level, stop here
    if get_level_weapon(ggPlayer.level) != "knife":
        return

    # Add the player to recentlyOffKnife for a short time so that we will know
    # in player_death that they just leveled up off of knife level
    recentlyOffKnife.append(ggPlayer.userid)
    gamethread.delayed(0.2, recentlyOffKnife.remove, ggPlayer.userid)
Example #14
0
def level_call_back(name, value, ggPlayer):
    # If the player is getting their level attribute set for the first time, we
    # can't get it yet
    if not hasattr(ggPlayer, "level"):
        return

    # If the player did not level up to hegrenade level, stop here
    if get_level_weapon(value) != "hegrenade":
        return

    # Add the player to recentlyOnHegrenade for a short time so that we will
    # know in player_death that they just leveled up to hegrenade level
    recentlyOnHegrenade.append(ggPlayer.userid)
    delayed(0.2, recentlyOnHegrenade.remove, ggPlayer.userid)
Example #15
0
def level_call_back(name, value, ggPlayer):
    # If the player is getting their level attribute set for the first time, we
    # can't get it yet
    if not hasattr(ggPlayer, "level"):
        return

    # If the player did not level up to hegrenade level, stop here
    if get_level_weapon(value) != "hegrenade":
        return

    # Add the player to recentlyOnHegrenade for a short time so that we will
    # know in player_death that they just leveled up to hegrenade level
    recentlyOnHegrenade.append(ggPlayer.userid)
    delayed(0.2, recentlyOnHegrenade.remove, ggPlayer.userid)
Example #16
0
def level_call_back(name, value, ggPlayer):
    # If the player is getting their level attribute set for the first time, we
    # can't get it yet
    if not hasattr(ggPlayer, "level"):
        return

    # If the player did not level up off of knife level, stop here
    if get_level_weapon(ggPlayer.level) != "knife":
        return

    # Add the player to recentlyOffKnife for a short time so that we will know
    # in player_death that they just leveled up off of knife level
    recentlyOffKnife.append(ggPlayer.userid)
    gamethread.delayed(0.2, recentlyOffKnife.remove, ggPlayer.userid)
Example #17
0
def send_level_info_hudhint(ggPlayer):
    # Get the level, total number of levels and leader level for the hudhint
    level = ggPlayer.level
    totalLevels = get_total_levels()
    leaderLevel = get_leader_level()

    # Create a string for the hudhint
    text = langstring('LevelInfo_CurrentLevel',
                      tokens={
                          'level': level,
                          'total': totalLevels
                      },
                      userid=ggPlayer.userid)

    text += langstring('LevelInfo_CurrentWeapon',
                       tokens={'weapon': ggPlayer.weapon},
                       userid=ggPlayer.userid)
    multiKill = get_level_multikill(level)
    if multiKill > 1:
        text += langstring('LevelInfo_RequiredKills',
                           tokens={
                               'kills': ggPlayer.multikill,
                               'total': get_level_multikill(level)
                           },
                           userid=ggPlayer.userid)

    leaderTokens = {}
    # Choose the leaderString based on the player's leadership status
    if get_leader_count() == 0:
        leaderString = 'LevelInfo_NoLeaders'
    elif is_leader(ggPlayer.userid):
        leaderString = 'LevelInfo_CurrentLeader'
        if get_leader_count() > 1:
            leaderString = 'LevelInfo_AmongstLeaders'
    else:
        leaderString = 'LevelInfo_LeaderLevel'
        leaderTokens = {
            'level': leaderLevel,
            'total': totalLevels,
            'weapon': get_level_weapon(leaderLevel)
        }

    text += langstring(leaderString,
                       tokens=leaderTokens,
                       userid=ggPlayer.userid)

    # Send the level information hudhint
    ggPlayer.hudhint(text)
def getLevelupList(currentLevel, levelupLevel):
    levelupList = []

    # Get the total number of levels
    totalLevels = get_total_levels()

    # If the player would exceed the total number of levels, stop at the total
    if levelupLevel > totalLevels:
        levelupLevel = totalLevels

    # Create a list of the weapon names for levels we plan to level the player
    # up past
    for level in xrange(currentLevel + 1, levelupLevel):
        levelupList.append(get_level_weapon(level))

    # Return the list
    return levelupList
Example #19
0
def getLevelupList(currentLevel, levelupLevel):
    levelupList = []

    # Get the total number of levels
    totalLevels = get_total_levels()

    # If the player would exceed the total number of levels, stop at the total
    if levelupLevel > totalLevels:
        levelupLevel = totalLevels

    # Create a list of the weapon names for levels we plan to level the player
    # up past
    for level in xrange(currentLevel + 1, levelupLevel):
        levelupList.append(get_level_weapon(level))

    # Return the list
    return levelupList
Example #20
0
    def set_warmup_weapon(self):
        '''Used to set the Warmup Weapon'''

        # Did the weapon just get set on load?
        if self.set_on_load:

            # Return the weapon that was already selected
            return self.weapon

        # Is the variable set to a specific weapon?
        if str(warmup_weapon) in possible_weapons:

            # Return the weapon
            return str(warmup_weapon)

        # Are there weapons in the weapon list?
        if len(self.list_of_weapons):

            # Return the next weapon
            return self.list_of_weapons.pop(0)

        # Is the weapon supposed to be random?
        if str(warmup_weapon) == '#random':

            # Get all weapons
            self.list_of_weapons = list(possible_weapons)

            # Randomize the weapons
            shuffle(self.list_of_weapons)

            # Return the first weapon
            return self.list_of_weapons.pop(0)

        # Is there a specific list of weapons?
        if ',' in str(warmup_weapon):

            # Create a list of the weapons
            self.list_of_weapons = str(warmup_weapon).split(',')

            # Return the first weapon
            return self.list_of_weapons.pop(0)

        # If all else fails, return the first level weapon
        return get_level_weapon(1)
Example #21
0
    def set_warmup_weapon(self):
        """Used to set the Warmup Weapon"""

        # Did the weapon just get set on load?
        if self.set_on_load:

            # Return the weapon that was already selected
            return self.weapon

        # Is the variable set to a specific weapon?
        if str(warmup_weapon) in possible_weapons:

            # Return the weapon
            return str(warmup_weapon)

        # Are there weapons in the weapon list?
        if len(self.list_of_weapons):

            # Return the next weapon
            return self.list_of_weapons.pop(0)

        # Is the weapon supposed to be random?
        if str(warmup_weapon) == "#random":

            # Get all weapons
            self.list_of_weapons = list(possible_weapons)

            # Randomize the weapons
            shuffle(self.list_of_weapons)

            # Return the first weapon
            return self.list_of_weapons.pop(0)

        # Is there a specific list of weapons?
        if "," in str(warmup_weapon):

            # Create a list of the weapons
            self.list_of_weapons = str(warmup_weapon).split(",")

            # Return the first weapon
            return self.list_of_weapons.pop(0)

        # If all else fails, return the first level weapon
        return get_level_weapon(1)
Example #22
0
def send_level_info_hudhint(ggPlayer):
    # Get the level, total number of levels and leader level for the hudhint
    level = ggPlayer.level
    totalLevels = get_total_levels()
    leaderLevel = get_leader_level()

    # Create a string for the hudhint
    text = langstring('LevelInfo_CurrentLevel', tokens={
                            'level': level,
                            'total': totalLevels},
                            userid=ggPlayer.userid)

    text += langstring('LevelInfo_CurrentWeapon', tokens={
                            'weapon': ggPlayer.weapon},
                            userid=ggPlayer.userid)
    multiKill = get_level_multikill(level)
    if multiKill > 1:
        text += langstring('LevelInfo_RequiredKills', tokens={
                            'kills': ggPlayer.multikill,
                            'total': get_level_multikill(level)},
                            userid=ggPlayer.userid)

    leaderTokens = {}
    # Choose the leaderString based on the player's leadership status
    if get_leader_count() == 0:
        leaderString = 'LevelInfo_NoLeaders'
    elif is_leader(ggPlayer.userid):
        leaderString = 'LevelInfo_CurrentLeader'
        if get_leader_count() > 1:
            leaderString = 'LevelInfo_AmongstLeaders'
    else:
        leaderString = 'LevelInfo_LeaderLevel'
        leaderTokens = {'level': leaderLevel,
                    'total': totalLevels,
                    'weapon': get_level_weapon(leaderLevel)}

    text += langstring(leaderString,
        tokens=leaderTokens, userid=ggPlayer.userid)

    # Send the level information hudhint
    ggPlayer.hudhint(text)
Example #23
0
def give_weapon(userid, previousLevel):
    if not es.exists('userid', userid) and userid != 0:
        return

    # Is spectator?
    if es.getplayerteam(userid) < 2:
        return

    # Get playerlib object
    pPlayer = getPlayer(userid)

    # Is player dead?
    if pPlayer.isdead:
        return

    # Give them their next weapon
    ggPlayer = Player(userid)
    ggPlayer.give_weapon()

    # If previousLevel is not in the order due to weapon orders changing,
    # stop here
    if previousLevel > get_total_levels():
        return

    weapsToStrip = [get_level_weapon(previousLevel)]

    # If the player is was on hegrenade level, and gg_nade_bonus is enabled,
    # and the current level is not hegrenade as well, get the list of their
    # bonus weapons
    if (weapsToStrip[0] == "hegrenade" and str(gg_nade_bonus) != "0"
            and ggPlayer.weapon != "hegrenade"):
        weapsToStrip.extend(get_weapon(userid))

    # If any weapons to be removed were just given, do not strip them
    if ggPlayer.weapon in weapsToStrip:
        weapsToStrip.remove(ggPlayer.weapon)

    # Strip the previous weapons
    ggPlayer.strip_weapons(weapsToStrip)
Example #24
0
def give_weapon(userid, previousLevel):
    if not es.exists('userid', userid) and userid != 0:
        return

    # Is spectator?
    if es.getplayerteam(userid) < 2:
        return

    # Get playerlib object
    pPlayer = getPlayer(userid)

    # Is player dead?
    if pPlayer.isdead:
        return

    # Give them their next weapon
    ggPlayer = Player(userid)
    ggPlayer.give_weapon()

    # If previousLevel is not in the order due to weapon orders changing,
    # stop here
    if previousLevel > get_total_levels():
        return

    weapsToStrip = [get_level_weapon(previousLevel)]

    # If the player is was on hegrenade level, and gg_nade_bonus is enabled,
    # and the current level is not hegrenade as well, get the list of their
    # bonus weapons
    if (weapsToStrip[0] == "hegrenade" and
      str(gg_nade_bonus) != "0" and ggPlayer.weapon != "hegrenade"):
        weapsToStrip.extend(get_weapon(userid))

    # If any weapons to be removed were just given, do not strip them
    if ggPlayer.weapon in weapsToStrip:
        weapsToStrip.remove(ggPlayer.weapon)

    # Strip the previous weapons
    ggPlayer.strip_weapons(weapsToStrip)
Example #25
0
def weapons_menu_cmd(userid, args):
    # Make sure player exists
    if not es.exists('userid', userid) and userid != 0:
        return

    weaponOrder = []
    level = 1
    totalLevels = get_total_levels()

    while level <= totalLevels:
        weaponOrder.append("[%s] %s" % (get_level_multikill(level),
            get_level_weapon(level)))
        level += 1

    # Get the level the player is on
    ggLevel = Player(userid).level

    # Create a new OrderedMenu
    ggWeaponsMenu = OrderedMenu(userid, 'GunGame: Weapons Menu', weaponOrder,
                                                    highlightIndex=ggLevel)

    # Send the OrderedMenu on the page the player's weapon is on
    ggWeaponsMenu.send_page(get_index_page(ggLevel))
Example #26
0
    def send_round_start_messages(self):
        '''Sends level info for both teams on round_start'''

        # Set the message type
        message = 'TeamPlay_Round'

        # Get the team's weapon
        weapon = get_level_weapon(self.level)

        tokens = {'level': self.level, 'weapon': weapon}

        # Get the team's current level's multikill
        multikill = get_level_multikill(self.level)

        # Is the needed multikill > 1?
        if multikill > 1:

            # Set the message type to use multikill
            message += '_Multikill'

            # Add multikill values to the tokens
            tokens.update({'multikill': self.multikill, 'needed': multikill})

        self.send_all_players_a_message(message, tokens)
Example #27
0
    def send_round_start_messages(self):
        '''Sends level info for both teams on round_start'''

        # Set the message type
        message = 'TeamPlay_Round'

        # Get the team's weapon
        weapon = get_level_weapon(self.level)

        tokens = {'level': self.level, 'weapon': weapon}

        # Get the team's current level's multikill
        multikill = get_level_multikill(self.level)

        # Is the needed multikill > 1?
        if multikill > 1:

            # Set the message type to use multikill
            message += '_Multikill'

            # Add multikill values to the tokens
            tokens.update({'multikill': self.multikill, 'needed': multikill})

        self.send_all_players_a_message(message, tokens)
Example #28
0
    def send_level_message(self):
        '''Sends a message to all players about the teams new level'''

        # Send the message to all players
        self.send_all_players_a_message('TeamWork_TeamLevel',
            {'level': self.level, 'weapon': get_level_weapon(self.level)})
Example #29
0
def give_bonus(userid, sound=False, turboCheck=False):
    ggPlayer = Player(userid)

    # Using weapon list?
    if using_weapon_list():

        # Player needs a real levelup?
        totalLevels = get_total_levels(str(gg_nade_bonus))
        if totalLevels < ggPlayer.nadeBonusLevel:

            # Reset bonus multi kills
            ggPlayer.nadeBonusMulti = 0

            # Player stuck on last gun ?
            if int(gg_nade_bonus_mode) == 0:
                ggPlayer.nadeBonusLevel = totalLevels
                return

            # Resetting player's bonus level
            ggPlayer.nadeBonusLevel = 1

            # Put the player back on level 1 ?
            if int(gg_nade_bonus_mode) == 1:

                # Recall the function to give level 1 weapon
                give_bonus(userid, sound, turboCheck)

                # Strip the previous weapons
                ggPlayer.strip_weapons([
                    get_level_weapon(get_total_levels(str(gg_nade_bonus)),
                                     str(gg_nade_bonus))
                ])
                return

            # Level them up
            ggPlayer.levelup(1, userid, 'kill')

            # Play the levelup sound
            ggPlayer.playsound('levelup')

            # Strip the previous weapons
            ggPlayer.strip_weapons([
                get_level_weapon(get_total_levels(str(gg_nade_bonus)),
                                 str(gg_nade_bonus))
            ])

            # Display message
            ggPlayer.msg('Levelup', {}, True)

            return

    # Play sound ?
    if sound:
        ggPlayer.playsound('nadebonuslevel')

    # gg_turbo is loaded ?
    if turboCheck and not int(es.ServerVar('gg_turbo')):
        return

    # Get weapon
    weapons = get_weapon(userid)

    # All you get is a knife?
    if len(weapons) == 1 and weapons[0] == 'knife':

        # Not carrying a nade?
        if getPlayer(userid).get('he') == 0:

            # Pull out knife
            es.sexec(userid, 'use weapon_knife')

        return

    # Give weapons
    count = 0
    for weapon in weapons:

        # If the weapon is flashbang, and it is not the first flashbang in the
        # list, give it without stripping the first one we gave, and continue
        if (weapon == "flashbang" and weapons.count("flashbang") > 1
                and count != weapons.index("flashbang")):

            ggPlayer.give(weapon, False, False)
            continue

        count += 1

        ggPlayer.give(weapon, False, True)

    # if they are carrying an hegrenade, make them use it
    if getPlayer(userid).get('he') != 0:
        es.sexec(userid, 'use weapon_hegrenade')

    # If a weapon list is being used, strip the previous weapons
    if using_weapon_list():
        previousLevel = Player(userid).nadeBonusLevel - 1
        # If their level just started the loop again, their previous level is
        # the total number of levels
        if previousLevel < 1:
            previousLevel = get_total_levels(str(gg_nade_bonus))
            # If the total number of levels is 1, don't strip them
            if previousLevel == 1:
                return

        # Strip the previous weapons
        ggPlayer.strip_weapons(
            [get_level_weapon(previousLevel, str(gg_nade_bonus))])
Example #30
0
def give_bonus(userid, sound=False, turboCheck=False):
    ggPlayer = Player(userid)

    # Using weapon list?
    if using_weapon_list():

        # Player needs a real levelup?
        totalLevels = get_total_levels(str(gg_nade_bonus))
        if totalLevels < ggPlayer.nadeBonusLevel:

            # Reset bonus multi kills
            ggPlayer.nadeBonusMulti = 0

            # Player stuck on last gun ?
            if int(gg_nade_bonus_mode) == 0:
                ggPlayer.nadeBonusLevel = totalLevels
                return

            # Resetting player's bonus level
            ggPlayer.nadeBonusLevel = 1

            # Put the player back on level 1 ?
            if int(gg_nade_bonus_mode) == 1:

                # Recall the function to give level 1 weapon
                give_bonus(userid, sound, turboCheck)

                # Strip the previous weapons
                ggPlayer.strip_weapons([get_level_weapon(
                    get_total_levels(str(gg_nade_bonus)), str(gg_nade_bonus))])
                return

            # Level them up
            ggPlayer.levelup(1, userid, 'kill')

            # Play the levelup sound
            ggPlayer.playsound('levelup')

            # Strip the previous weapons
            ggPlayer.strip_weapons([get_level_weapon(get_total_levels(
                                    str(gg_nade_bonus)), str(gg_nade_bonus))])

            # Display message
            ggPlayer.msg('Levelup', {}, True)

            return

    # Play sound ?
    if sound:
        ggPlayer.playsound('nadebonuslevel')

    # gg_turbo is loaded ?
    if turboCheck and not int(es.ServerVar('gg_turbo')):
        return

    # Get weapon
    weapons = get_weapon(userid)

    # All you get is a knife?
    if len(weapons) == 1 and weapons[0] == 'knife':

        # Not carrying a nade?
        if getPlayer(userid).get('he') == 0:

            # Pull out knife
            es.sexec(userid, 'use weapon_knife')

        return

    # Give weapons
    count = 0
    for weapon in weapons:

        # If the weapon is flashbang, and it is not the first flashbang in the
        # list, give it without stripping the first one we gave, and continue
        if (weapon == "flashbang" and
          weapons.count("flashbang") > 1 and
          count != weapons.index("flashbang")):

            ggPlayer.give(weapon, False, False)
            continue

        count += 1

        ggPlayer.give(weapon, False, True)

    # if they are carrying an hegrenade, make them use it
    if getPlayer(userid).get('he') != 0:
        es.sexec(userid, 'use weapon_hegrenade')

    # If a weapon list is being used, strip the previous weapons
    if using_weapon_list():
        previousLevel = Player(userid).nadeBonusLevel - 1
        # If their level just started the loop again, their previous level is
        # the total number of levels
        if previousLevel < 1:
            previousLevel = get_total_levels(str(gg_nade_bonus))
            # If the total number of levels is 1, don't strip them
            if previousLevel == 1:
                return

        # Strip the previous weapons
        ggPlayer.strip_weapons([get_level_weapon(previousLevel,
                                                        str(gg_nade_bonus))])