Esempio n. 1
0
    def _load_configs(self):
        '''Loads all "main", "included", and "custom" addon config files'''

        # Print a message that the base cfg files
        # and the Included Addon cfg files are being loaded
        es.dbgmsg(0, langstring('Load_Configs'))

        # Loop through all base _config.py files
        for cfgfile in ConfigTypeDictionary.main:

            # Load the file
            self._load_config(cfgfile)

        # Loop through all Included Addon _config.py files
        for cfgfile in ConfigTypeDictionary.included:

            # Load the file
            self._load_config(cfgfile)

        # Print a message that the Custom Addon cfg files are being loaded
        es.dbgmsg(0, langstring('Load_CustomConfigs'))

        # Loop through all Custom Addon _config.py files
        for cfgfile in ConfigTypeDictionary.custom:

            # Load the file
            self._load_config(cfgfile)

        # Execute all cfg files in one tick
        delayed(0, self._execute_cfg_files)
Esempio n. 2
0
def cmd_spawn_print(args):
    es.dbgmsg(0, langstring("SpawnpointsFor", {"map": str(current_map)}))

    # Loop through all spawnpoints
    index = 0
    for spawnPoint in read_spawn_points():
        sp = spawnPoint.strip("\n").split(" ")
        es.dbgmsg(0, langstring("SpawnpointInfo", {"index": index, "x": sp[0],
                                                    "y": sp[1], "z": sp[2]}))
        index += 1
Esempio n. 3
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)
Esempio n. 4
0
def finish_initialization():
    '''Tries to finish GunGame's initialization'''

    # Fire the gg_server.cfg
    es.server.cmd('exec gungame51/gg_server.cfg')

    # Clear out the GunGame system
    reset_players()

    # Restart map
    msg('#human', 'Loaded')

    # Prune the DB
    prune_winners_db()

    # Load error logging
    delayed(3.50, make_log_file)

    # Fire gg_load event
    GG_Load().fire()

    # Send message that loading has completed
    es.dbgmsg(0, langstring("Load_Completed"))

    # Change the value of gg_weapon_order_file to make sure we call
    # server_cvar when reloading gungame51
    gg_weapon_order_file_backup = str(gg_weapon_order_file)
    gg_weapon_order_file.set(0)
    gg_weapon_order_file.set(gg_weapon_order_file_backup)

    # See if we need to fire event gg_start after everything is loaded
    delayed(2, check_first_gg_start)
Esempio n. 5
0
def initialize():
    '''Tries to initialize GunGame'''

    # Load GunGame's events
    load_events()

    # Load custom events
    gg_resource_file.declare_and_load()

    # Load the base translations
    load_translation('gungame', 'gungame')

    # Send message about GunGame loading
    es.dbgmsg(0, langstring("Load_Start",
                            {'version': gungame_info('version')}))

    # Load config files
    load_configs()

    # Load weapon orders
    WeaponOrderManager().load_orders()

    # Load menus
    MenuManager().load_menus()

    # Make the sounds downloadable
    make_downloadable(True)

    # Pause a moment for the configs to be loaded (OB engine requires this)
    delayed(0.1, complete_initialization)
Esempio n. 6
0
def finish_initialization():
    '''Tries to finish GunGame's initialization'''

    # Fire the gg_server.cfg
    es.server.cmd('exec gungame51/gg_server.cfg')

    # Clear out the GunGame system
    reset_players()

    # Restart map
    msg('#human', 'Loaded')

    # Prune the DB
    prune_winners_db()

    # Load error logging
    delayed(3.50, make_log_file)

    # Fire gg_load event
    GG_Load().fire()

    # Send message that loading has completed
    es.dbgmsg(0, langstring("Load_Completed"))

    # Change the value of gg_weapon_order_file to make sure we call
    # server_cvar when reloading gungame51
    gg_weapon_order_file_backup = str(gg_weapon_order_file)
    gg_weapon_order_file.set(0)
    gg_weapon_order_file.set(gg_weapon_order_file_backup)

    # See if we need to fire event gg_start after everything is loaded
    delayed(2, check_first_gg_start)
Esempio n. 7
0
    def send_all_players_a_message(self, message, tokens):
        '''Sends all players on the server a message'''

        # Store a team members index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, don't send any messages
            return

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the player a bot?
            if isbot(userid):

                # If so, don't send a message
                continue

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Update the tokens with the teamname
            tokens.update({'teamname': teamname})

            # Send the message to the player
            Player(userid).saytext2(index, message, tokens, True)
Esempio n. 8
0
def initialize():
    '''Tries to initialize GunGame'''

    # Load GunGame's events
    load_events()

    # Load custom events
    gg_resource_file.declare_and_load()

    # Load the base translations
    load_translation('gungame', 'gungame')

    # Send message about GunGame loading
    es.dbgmsg(0, langstring("Load_Start",
            {'version': gungame_info('version')}))

    # Load config files
    load_configs()

    # Load weapon orders
    WeaponOrderManager().load_orders()

    # Load menus
    MenuManager().load_menus()

    # Make the sounds downloadable
    make_downloadable(True)

    # Pause a moment for the configs to be loaded (OB engine requires this)
    delayed(0.1, complete_initialization)
Esempio n. 9
0
    def send_all_players_a_message(self, message, tokens):
        '''Sends all players on the server a message'''

        # Store a team members index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, don't send any messages
            return

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the player a bot?
            if isbot(userid):

                # If so, don't send a message
                continue

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Update the tokens with the teamname
            tokens.update({'teamname': teamname})

            # Send the message to the player
            Player(userid).saytext2(index, message, tokens, True)
Esempio n. 10
0
def gg_addon_unloaded(event_var):
    '''Called when a sub-addon is unloaded'''

    es.dbgmsg(
        0,
        langstring('Addon_UnLoaded', {
            'addon': event_var['addon'],
            'type': event_var['type']
        }))
Esempio n. 11
0
def cmd_spawn_remove_all(args):
    write_spawn_points([])
    es.dbgmsg(0, langstring("RemovedAllSpawnpoints"))

    # If spawnpoints are currently being shown, toggle spawn_show off and on to
    # update the spawnpoints shown
    if len(propIndexes):
        cmd_spawn_show()
        cmd_spawn_show()
Esempio n. 12
0
def cmd_spawn_add(args):
    # More than one argument was passed
    if len(args) != 1:
        invalid_syntax("spawn_add <userid>")
        return

    # A non-integer was passed
    userid = args[0]
    if not userid.isdigit():
        invalid_syntax("spawn_add <userid>")
        return

    # The userid does not exist
    if not es.exists("userid", userid):
        es.dbgmsg(0, langstring("OperationFailed:InvalidUserid",
                                                        {"userid": userid}))
        return

    pPlayer = getPlayer(userid)
    location = es.getplayerlocation(userid)
    angle = pPlayer.get("viewangle")

    spawnPoint = "%s %s %s %s %s %s\n" % (location + angle)
    currentSpawnPoints = read_spawn_points()

    # If the spawnpoint already exists, stop here
    for sp in currentSpawnPoints:
        if sp.split(" ")[0:3] == spawnPoint.split(" ")[0:3]:
            es.dbgmsg(0, "Spawnpoint already exists.")
            return

    # Add the spawnpoint
    currentSpawnPoints.append(spawnPoint)

    write_spawn_points(currentSpawnPoints)
    es.dbgmsg(
        0, langstring("AddedSpawnpoint", {"point": spawnPoint.strip("\n")}))

    # If spawnpoints are currently being shown, toggle spawn_show off and on to
    # update the spawnpoints shown
    if len(propIndexes):
        cmd_spawn_show()
        cmd_spawn_show()
Esempio n. 13
0
def voteCountDown():
    ggRepeat = repeat.find('gg_map_vote')
    if not ggRepeat:
        return

    timeleft = ggRepeat['remaining']

    # Stop the vote ?
    if timeleft == 0:
        voteEnd()
        return

    votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values()))

    voteInfo = ""
    mapsAdded = 0
    # For the map with the most votes to the least
    sortItems = []
    for map in mapVoteOptions.items():
        sortItems.append((map[0], len(map[1])))

    for map in sorted(sortItems, key=itemgetter(1), reverse=True):
        # Add up to three maps
        voteInfo += langstring('MapVotes',
                               tokens={
                                   'map': map[0],
                                   'votes': map[1]
                               })
        mapsAdded += 1
        if mapsAdded >= 3:
            break

    # Should we play the countdown beep
    if timeleft <= 5:
        for userid in getUseridList('#human'):
            Player(userid).playsound('countDownBeep')

        # Show the singular hudhint and stop here
        if timeleft == 1:
            hudhint(
                '#human', 'Countdown_Singular', {
                    'time': timeleft,
                    'voteInfo': voteInfo,
                    'votes': votes,
                    'totalVotes': len(voteUserids)
                })
            return
    # Show the normal hudhint
    hudhint(
        '#human', 'Countdown_Plural', {
            'time': timeleft,
            'voteInfo': voteInfo,
            'votes': votes,
            'totalVotes': len(voteUserids)
        })
Esempio n. 14
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)
Esempio n. 15
0
 def echo(self):
     '''
     Echos (prints) the current weapon order to console.
     '''
     es.dbgmsg(0, ' ')
     es.dbgmsg(0, '[GunGame] ' + langstring('WeaponOrder:Echo',
                                                 {'file': self.title}))
     es.dbgmsg(0, ' ')
     echo_string = langstring('WeaponOrder:Echo:TableColumns')
     echo_lengths = [len(x) for x in echo_string.split('|')[1:4]]
     echo_columns = '+'.join(['-' * x for x in echo_lengths]) + '+'
     es.dbgmsg(0, '[GunGame] +' + echo_columns)
     es.dbgmsg(0, '[GunGame] ' + echo_string)
     es.dbgmsg(0, '[GunGame] +' + echo_columns)
     for level in self.active:
         weapon = self.active[level].weapon
         multikill = self.active[level].kills
         es.dbgmsg(0, '[GunGame] |%s|%s|%s |' % (
                     str(level).center(echo_lengths[0]),
                     str(multikill).center(echo_lengths[1]),
                     weapon.rjust(echo_lengths[2] - 1)))
     es.dbgmsg(0, '[GunGame] +' + echo_columns)
Esempio n. 16
0
def voteCountDown():
    ggRepeat = repeat.find("gg_map_vote")
    if not ggRepeat:
        return

    timeleft = ggRepeat["remaining"]

    # Stop the vote ?
    if timeleft == 0:
        voteEnd()
        return

    votes = len(reduce(lambda a, b: a + b, mapVoteOptions.values()))

    voteInfo = ""
    mapsAdded = 0
    # For the map with the most votes to the least
    sortItems = []
    for map in mapVoteOptions.items():
        sortItems.append((map[0], len(map[1])))

    for map in sorted(sortItems, key=itemgetter(1), reverse=True):
        # Add up to three maps
        voteInfo += langstring("MapVotes", tokens={"map": map[0], "votes": map[1]})
        mapsAdded += 1
        if mapsAdded >= 3:
            break

    # Should we play the countdown beep
    if timeleft <= 5:
        for userid in getUseridList("#human"):
            Player(userid).playsound("countDownBeep")

        # Show the singular hudhint and stop here
        if timeleft == 1:
            hudhint(
                "#human",
                "Countdown_Singular",
                {"time": timeleft, "voteInfo": voteInfo, "votes": votes, "totalVotes": len(voteUserids)},
            )
            return
    # Show the normal hudhint
    hudhint(
        "#human",
        "Countdown_Plural",
        {"time": timeleft, "voteInfo": voteInfo, "votes": votes, "totalVotes": len(voteUserids)},
    )
Esempio n. 17
0
    def send_winner_messages(self):
        '''Sends Winner Messages to all players'''

        # Store a team player's index
        index = self.index

        # Is there an index?
        if index is None:

            # If not, return
            return

        # Store the team's color
        color = self.color

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the current player a bot?
            if isbot(userid):

                # Do not send messages to bots
                continue

            # Get the player's Player() instance
            ggPlayer = Player(userid)

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Send chat message for team winning the match
            ggPlayer.saytext2(
                index, 'TeamWork_Winner', {'teamname': teamname}, True)

            # We want to loop, so we send a message every second for 3 seconds
            for x in xrange(4):

                # Send centermsg about the winner
                delayed(x, ggPlayer.centermsg,
                    ('TeamWork_Winner_Center', {'teamname': teamname}))

            # Send toptext message about the winner
            ggPlayer.toptext(10, color,
                'TeamWork_Winner_Center', {'teamname': teamname})
Esempio n. 18
0
    def send_winner_messages(self):
        '''Sends Winner Messages to all players'''

        # Store a team player's index
        index = self.index

        # Store the team's color
        color = self.color

        # Loop through all players on the server
        for userid in getUseridList():

            # Is the current player a bot?
            if isbot(userid):

                # Do not send messages to bots
                continue

            # Get the player's Player() instance
            ggPlayer = Player(userid)

            # Get the team's name
            teamname = langstring(self.teamname, userid=userid)

            # Send chat message for team winning the match
            ggPlayer.saytext2(index, 'TeamPlay_Winner', {'teamname': teamname},
                              True)

            # We want to loop, so we send a message every second for 3 seconds
            for x in xrange(4):

                # Send centermsg about the winner
                delayed(x, ggPlayer.centermsg, ('TeamPlay_Winner_Center', {
                    'teamname': teamname
                }))

            # Send toptext message about the winner
            ggPlayer.toptext(10, color, 'TeamPlay_Winner_Center',
                             {'teamname': teamname})
Esempio n. 19
0
def make_downloadable(gg_loading=False):
    # Make the global variable winnerSounds global to this function in case we
    # use it below
    global winnerSounds

    # Is GunGame loading?
    if gg_loading:

        # Print message to server console
        es.dbgmsg(0, langstring('Load_SoundSystem'))

    # Make sure we are in a map
    if not in_map():
        return

    # Loop through all files in the sound_pack directory
    for f in iniDir.walkfiles():

        # Make sure the extension is ".ini"
        if f.ext.lower() != '.ini':
            continue

        # Grab the ConfigObj for the INI
        config = ConfigObj('%s/%s' % (iniDir, f.name))

        # Loop through all names (keys) in the INI
        for name in config:

            # Make sure the name isn't "title"
            if name.lower() == 'title':
                continue

            # Make sure that the sound file exists at the given path
            if sound_exists(config[name]):

                # Make the sound downloadable
                es.stringtable('downloadables', 'sound/%s' % config[name])

            else:

                # See if the file is a random sound text file
                if not iniDir.joinpath('random_sound_files',
                                       config[name]).isfile():
                    continue

                # If we are on a random winner sound, and we have more sounds
                # in the current list of random sounds, choose one and make it
                # downloadable
                if name == "winner" and winnerSounds:
                    # If there are winner sounds left in the shuffled list,
                    # remove the last used sound
                    if len(winnerSounds) > 1:
                        winnerSounds.pop(0)
                        # Make the new random winner sound downloadable
                        if sound_exists(winnerSounds[0]):
                            es.stringtable('downloadables',
                                           'sound/%s' % winnerSounds[0])
                        # If gg_dynamic_chattime is enabled, set the chattime
                        if int(gg_dynamic_chattime):
                            set_chattime()

                        continue
                    # If the last used winner sound is the only thing left,
                    # clear the list so that we can fill it below
                    winnerSounds = []

                # Open the random sound file
                with iniDir.joinpath('random_sound_files',
                                     config[name]).open() as randomFile:

                    randomSounds = randomFile.readlines()

                # Loop through all sounds in the file
                for sound in randomSounds:
                    # Remove the line return character and whitespace,
                    sound = sound.strip('\\n').strip()

                    # Do not add comment lines
                    if sound.startswith("//"):
                        continue

                    # If we are on a random winner sound, add it to the
                    # random winner sounds list
                    if name == "winner":
                        winnerSounds.append(sound)

                        # We will make the winner sound chosen for this round
                        # downloadable below this loop
                        continue

                    # Make sure that the sound file exists at the given path
                    if sound_exists(sound):
                        # Make the sound downloadable
                        es.stringtable('downloadables', 'sound/%s' % sound)

                # Now that we are done adding random winner sounds to
                # the winnerSounds list, choose one to make downloadable
                if name == "winner":
                    # Shuffle the list of new winner sounds
                    shuffle(winnerSounds)
                    # Make the new random winner sound downloadable
                    if sound_exists(winnerSounds[0]):
                        es.stringtable('downloadables',
                                       'sound/%s' % winnerSounds[0])
                    # If gg_dynamic_chattime is enabled, set the chattime
                    if int(gg_dynamic_chattime):
                        set_chattime()
Esempio n. 20
0
 def load_menus(self):
     es.dbgmsg(0, langstring("Load_Commands"))
     for file_path in menu_folder.files("*_menu.py"):
         self._load(file_path)
Esempio n. 21
0
def cmd_spawn_show(args=None):
    userid = es.getuserid()

    # If there are no players on the map, stop here
    if not userid:
        return

    # If spawnpoints are currently being shown, toggle them off and stop here
    if len(propIndexes):
        entityIndexes = es.getEntityIndexes("prop_dynamic")

        for index in propIndexes:
            if propIndexes[index] in entityIndexes:
                es.server.cmd("es_xremove gg_sp_prop%i" % int(index))
        propIndexes.clear()
        return

    # Loop through the spawnpoints
    count = 0
    for spawnPoint in read_spawn_points():
        spawnPoint = spawnPoint.strip("\n")
        location = []
        angle = []
        location.extend(spawnPoint.split(" ")[0:3])
        angle.extend(spawnPoint.split(" ")[3:6])

        # Create prop and name it
        playerView = getPlayer(userid).get("viewangle")
        es.server.cmd("es_xprop_dynamic_create %s %s" % (userid, propModel))
        es.server.cmd("es_xentsetname %s gg_sp_prop%i" % (userid, count))
        es.server.cmd("es_xsetang %i %f %f" % (userid, playerView[0],
                                                playerView[1]))

        # Get index
        propIndex = int(es.ServerVar("eventscripts_lastgive"))

        # Set position and collision group
        es.setindexprop(propIndex, "CBaseEntity.m_CollisionGroup", 2)
        es.setindexprop(propIndex, "CBaseEntity.m_vecOrigin",
                                                "%s, %s, %s" % (location[0],
                                                                location[1],
                                                                location[2]))
        es.setindexprop(propIndex, "CBaseEntity.m_angRotation",
                                                "0, %s, 0" % angle[1])

        # Set aestetics
        es.server.cmd('es_xfire %s ' % userid +
            'prop_dynamic SetAnimation "walk_lower"')
        es.server.cmd('es_xfire %s ' % userid +
            'prop_dynamic SetDefaultAnimation  "walk_lower"')
        es.server.cmd('es_xfire %s ' % userid +
            'prop_dynamic AddOutput "rendermode 1"')
        es.server.cmd('es_xfire %s prop_dynamic alpha "160"' % userid)

        # Add to prop index points
        propIndexes[count] = propIndex
        count += 1

    # If there were no spawnpoitns to be shown, tell them
    if count == 0:
        es.dbgmsg(0, langstring("OperationFailed:NoSpawnpoints"))
Esempio n. 22
0
def gg_addon_unloaded(event_var):
    '''Called when a sub-addon is unloaded'''

    es.dbgmsg(0, langstring('Addon_UnLoaded',
        {'addon': event_var['addon'], 'type': event_var['type']}))
Esempio n. 23
0
def cmd_spawn_remove(args):
    # More than one argument was passed
    if len(args) != 1:
        invalid_syntax("spawn_remove <userid>")
        return

    # A non-integer was passed
    userid = args[0]
    if not userid.isdigit():
        invalid_syntax("spawn_remove <userid>")
        return

    # The userid does not exist
    if not es.exists('userid', userid) and userid != 0:
        es.dbgmsg(0, langstring("OperationFailed:InvalidUserid",
                                                        {"userid": userid}))
        return

    pPlayer = getPlayer(userid)
    location = es.getplayerlocation(userid)

    x, y, z = location[0], location[1], location[2]
    currentSpawnPoints = read_spawn_points()

    # There are no spawnpoints to remove
    if not currentSpawnPoints:
        es.dbgmsg(0, langstring("OperationFailed:NoSpawnpoints"))
        return

    index = 0
    count = 0
    lowestTotal = -1
    # Loop through the current spawnpoints
    for sp in currentSpawnPoints:
        spList = sp.split(' ')

        # Format the spawnpoint into a list of floats
        i = 0
        for s in spList:
            spList[i] = float(s)
            i += 1

        # Get the total distance from the spawnpoint (on x, y, and z axes)
        total = 0
        total += abs(x - spList[0])
        total += abs(y - spList[1])
        total += abs(z - spList[2])

        # If this is the first spawnpoint, or the new lowest total, save it
        if lowestTotal == -1 or total < lowestTotal:
            lowestTotal = total
            index = count

        count += 1

    # Remove the spawnpoint saved for having the lowest total distance
    spawnPoint = currentSpawnPoints.pop(index)

    write_spawn_points(currentSpawnPoints)
    es.dbgmsg(
        0, langstring("RemovedSpawnpoint", {"point": spawnPoint.strip("\n")}))

    # If spawnpoints are currently being shown, toggle spawn_show off and on to
    # update the spawnpoints shown
    if len(propIndexes):
        cmd_spawn_show()
        cmd_spawn_show()
Esempio n. 24
0
def make_downloadable(gg_loading=False):
    # Make the global variable winnerSounds global to this function in case we
    # use it below
    global winnerSounds

    # Is GunGame loading?
    if gg_loading:

        # Print message to server console
        es.dbgmsg(0, langstring('Load_SoundSystem'))

    # Make sure we are in a map
    if not in_map():
        return

    # Loop through all files in the sound_pack directory
    for f in iniDir.walkfiles():

        # Make sure the extension is ".ini"
        if f.ext.lower() != '.ini':
            continue

        # Grab the ConfigObj for the INI
        config = ConfigObj('%s/%s' % (iniDir, f.name))

        # Loop through all names (keys) in the INI
        for name in config:

            # Make sure the name isn't "title"
            if name.lower() == 'title':
                continue

            # Make sure that the sound file exists at the given path
            if sound_exists(config[name]):

                # Make the sound downloadable
                es.stringtable('downloadables', 'sound/%s' % config[name])

            else:

                # See if the file is a random sound text file
                if not iniDir.joinpath(
                  'random_sound_files', config[name]).isfile():
                    continue

                # If we are on a random winner sound, and we have more sounds
                # in the current list of random sounds, choose one and make it
                # downloadable
                if name == "winner" and winnerSounds:
                    # If there are winner sounds left in the shuffled list,
                    # remove the last used sound
                    if len(winnerSounds) > 1:
                        winnerSounds.pop(0)
                        # Make the new random winner sound downloadable
                        if sound_exists(winnerSounds[0]):
                            es.stringtable(
                                'downloadables', 'sound/%s' % winnerSounds[0])
                        # If gg_dynamic_chattime is enabled, set the chattime
                        if int(gg_dynamic_chattime):
                            set_chattime()

                        continue
                    # If the last used winner sound is the only thing left,
                    # clear the list so that we can fill it below
                    winnerSounds = []

                # Open the random sound file
                with iniDir.joinpath(
                  'random_sound_files', config[name]).open() as randomFile:

                    randomSounds = randomFile.readlines()

                # Loop through all sounds in the file
                for sound in randomSounds:
                    # Remove the line return character and whitespace,
                    sound = sound.strip('\\n').strip()

                    # Do not add comment lines
                    if sound.startswith("//"):
                        continue

                    # If we are on a random winner sound, add it to the
                    # random winner sounds list
                    if name == "winner":
                        winnerSounds.append(sound)

                        # We will make the winner sound chosen for this round
                        # downloadable below this loop
                        continue

                    # Make sure that the sound file exists at the given path
                    if sound_exists(sound):
                        # Make the sound downloadable
                        es.stringtable('downloadables', 'sound/%s' % sound)

                # Now that we are done adding random winner sounds to
                # the winnerSounds list, choose one to make downloadable
                if name == "winner":
                    # Shuffle the list of new winner sounds
                    shuffle(winnerSounds)
                    # Make the new random winner sound downloadable
                    if sound_exists(winnerSounds[0]):
                        es.stringtable(
                            'downloadables', 'sound/%s' % winnerSounds[0])
                    # If gg_dynamic_chattime is enabled, set the chattime
                    if int(gg_dynamic_chattime):
                        set_chattime()
Esempio n. 25
0
 def restart_game(self):
     self.active.echo()
     es.msg(langstring('WeaponOrder:ChangedTo', {'to': self.active.title}))
     es.ServerCommand('mp_restartgame 2')
Esempio n. 26
0
 def load_orders(self):
     es.dbgmsg(0, langstring("Load_WeaponOrders"))
     # Register for the server_cvar event
     es.addons.registerForEvent(self, 'server_cvar', self.server_cvar)
     for orderPath in weaponOrderFilesTXT:  # + weaponOrderFilesINI
         weaponOrderStorage.add(orderPath)
Esempio n. 27
0
 def load_menus(self):
     es.dbgmsg(0, langstring('Load_Commands'))
     for file_path in menu_folder.files('*_menu.py'):
         self._load(file_path)