示例#1
0
    def get_addon_ini(addon):
        # If the INI is the main GunGame INI, return the path to the INI
        if addon == "gungame":
            return get_game_dir("addons/eventscripts/gungame51/gungame.ini")

        # The INI must be either included or custom at this point
        from gungame51.core.addons.valid import ValidAddons

        # Get the addon type
        addon_type = ValidAddons.get_addon_type(addon)

        # Return the path to the addon INI
        return get_game_dir("addons/eventscripts/gungame51/scripts/" +
                            "%s/%s/%s.ini" % (addon_type, addon, addon))
示例#2
0
    def get_addon_ini(addon):
        # If the INI is the main GunGame INI, return the path to the INI
        if addon == "gungame":
            return get_game_dir("addons/eventscripts/gungame51/gungame.ini")

        # The INI must be either included or custom at this point
        from gungame51.core.addons.valid import ValidAddons

        # Get the addon type
        addon_type = ValidAddons.get_addon_type(addon)

        # Return the path to the addon INI
        return get_game_dir("addons/eventscripts/gungame51/scripts/" +
            "%s/%s/%s.ini" % (addon_type, addon, addon))
示例#3
0
def get_map_file():
    '''
    Stores the spawnpoint file for the current map in filePath
    '''
    global filePath
    filePath = get_game_dir(
        'cfg/gungame51/spawnpoints/' + str(current_map) + '.txt')
示例#4
0
def mapFileClean(fromLoad=False):
    # Using a custom list ?
    if int(gg_map_vote_list_source) != 3:
        return

    # Skip this part on initial load
    if not fromLoad:
        # Current source file
        current_file = get_game_dir(
            str(gg_map_vote_file) if not str(gg_map_vote_file).endswith(".txt") else str(gg_map_vote_file)
        )

        # Did it change ?
        if dict_mapListSource[3] != current_file:
            dict_mapListSource[3] = current_file

    # Look for it in /cstrike
    if dict_mapListSource[3].isfile():
        return

    # Look for file in other common folders
    for folder in ("cfg/", "cfg/gungame51/"):
        possible_path = get_game_dir(
            folder + "%s.txt" % str(gg_map_vote_file) if not ".txt" in str(gg_map_vote_file) else str(gg_map_vote_file)
        )

        # File exists in the other location ?
        if possible_path.isfile():
            dict_mapListSource[3] = possible_path
            es.dbgmsg(
                0,
                '>>>> GunGame has found "%s" ' % gg_map_vote_file
                + "in (%s) Please change your config file to " % folder
                + "reflect the location! (I.E. cfg/gungame51/myfile.txt)",
            )
            return

    # File couldn't be found, raising error
    raise IOError(
        "The file (%s) " % gg_map_vote_file
        + "could not be found!  GunGame attempted to find the "
        + "file in other locations and was unsuccessful.  The "
        + "server will default to the mapcycle.txt"
    )
示例#5
0
def mapFileClean(fromLoad=False):
    # Using a custom list ?
    if int(gg_map_vote_list_source) != 3:
        return

    # Skip this part on initial load
    if not fromLoad:
        # Current source file
        current_file = get_game_dir(
            str(gg_map_vote_file) if not str(gg_map_vote_file).endswith('.txt')
            else str(gg_map_vote_file))

        # Did it change ?
        if dict_mapListSource[3] != current_file:
            dict_mapListSource[3] = current_file

    # Look for it in /cstrike
    if dict_mapListSource[3].isfile():
        return

    # Look for file in other common folders
    for folder in ('cfg/', 'cfg/gungame51/'):
        possible_path = get_game_dir(
            folder + '%s.txt' % str(gg_map_vote_file)
            if not '.txt' in str(gg_map_vote_file) else str(gg_map_vote_file))

        # File exists in the other location ?
        if possible_path.isfile():
            dict_mapListSource[3] = possible_path
            es.dbgmsg(
                0, '>>>> GunGame has found "%s" ' % gg_map_vote_file +
                'in (%s) Please change your config file to ' % folder +
                'reflect the location! (I.E. cfg/gungame51/myfile.txt)')
            return

    # File couldn't be found, raising error
    raise IOError('The file (%s) ' % gg_map_vote_file +
                  'could not be found!  GunGame attempted to find the ' +
                  'file in other locations and was unsuccessful.  The ' +
                  'server will default to the mapcycle.txt')
示例#6
0
    def register_for_events(self):
        '''Method used to register events to be logged'''

        # Open the file that lists the events to log
        with get_game_dir('cfg/gungame51/' +
          'included_addon_configs/gg_stats_logging.txt').open() as f:

            # Store all events listed in the file
            self.list_events = [
              x.strip() for x in f.readlines() if not x.startswith('//') and x]

        # Loop through all events to be logged
        for event in self.list_events:

            # Register the event to be logged
            es.addons.registerForEvent(self, event, self.log_event)
示例#7
0
def buildPopups():
    # Get the custom text for the popup
    with get_game_dir(
            'cfg/gungame51/' +
            'included_addon_configs/gg_welcome_msg.txt').open() as customFile:
        customText = customFile.readlines()

    # Remove unnecessary characters
    customText = [x.strip() for x in customText]
    # Ignore commented lines
    customText = filter(lambda x: x[:2] != '//', customText)

    # Create a new popuplib instance
    menu = popuplib.create('gg_welcome')
    menu.addline(title)
    menu.addline('-' * 30)

    # For each line of custom text
    for line in customText:
        # If there is nothing on the line, make it a single space to show up
        # on the menu
        if not line:
            line = ' '

        # Replace variables in the line
        line = line.replace('$server', str(es.ServerVar('hostname')))
        line = line.replace('$date', time.strftime('%d/%m/%Y'))
        line = line.replace('$time', time.strftime('%H:%M:%S'))

        # Add the line to the menu
        menu.addline(line)

    # Create the rest of the menu
    menu.addline('-' * 30)
    menu.addline('->1. Included Addons')
    menu.select(1, welcome_handler)
    menu.addline('->2. Custom Addons')
    menu.select(2, welcome_handler)
    menu.addline('-' * 30)
    menu.addline('0. Cancel')

    # Set the timeout for the menu
    menu.timeout('send', int(gg_welcome_msg_timeout))
    menu.timeout('view', int(gg_welcome_msg_timeout))
示例#8
0
def buildPopups():
    # Get the custom text for the popup
    with get_game_dir('cfg/gungame51/' +
      'included_addon_configs/gg_welcome_msg.txt').open() as customFile:
        customText = customFile.readlines()

    # Remove unnecessary characters
    customText = [x.strip() for x in customText]
    # Ignore commented lines
    customText = filter(lambda x: x[:2] != '//', customText)

    # Create a new popuplib instance
    menu = popuplib.create('gg_welcome')
    menu.addline(title)
    menu.addline('-' * 30)

    # For each line of custom text
    for line in customText:
        # If there is nothing on the line, make it a single space to show up
        # on the menu
        if not line:
            line = ' '

        # Replace variables in the line
        line = line.replace('$server', str(es.ServerVar('hostname')))
        line = line.replace('$date', time.strftime('%d/%m/%Y'))
        line = line.replace('$time', time.strftime('%H:%M:%S'))

        # Add the line to the menu
        menu.addline(line)

    # Create the rest of the menu
    menu.addline('-' * 30)
    menu.addline('->1. Included Addons')
    menu.select(1, welcome_handler)
    menu.addline('->2. Custom Addons')
    menu.select(2, welcome_handler)
    menu.addline('-' * 30)
    menu.addline('0. Cancel')

    # Set the timeout for the menu
    menu.timeout('send', int(gg_welcome_msg_timeout))
    menu.timeout('view', int(gg_welcome_msg_timeout))
示例#9
0
def write_spawnpoint_file(fileName, mapName, convertedSpawnPoints):
    # The name of the new spawnpoints file
    newFileName = mapName + '.txt'

    # The path to the new spawnpoints file
    newFilePath = get_game_dir('/cfg/gungame51/spawnpoints/' + newFileName)

    # If the spawnpoints are being overwritten, or there are no current
    # spawnpoints, create an empty list for them
    if int(gg_convert) == 2 or not newFilePath.isfile():
        currentSpawnPoints = []

    # If there are current spawnpoints, save them in a list
    else:

        with newFilePath.open() as newFile:
            currentSpawnPoints = newFile.readlines()

    # Copy the converted spawnpoints so that we can remove the original
    # converted spawnpoints during the for loop iteration
    convertedSpawnPoints_copy = convertedSpawnPoints[:]

    # For every current spawnpoint
    for currentPoint in currentSpawnPoints:

        # For every converted spawnpoint
        for convertedPoint in convertedSpawnPoints_copy:

            # If the x, y and z are equal, remove the converted spawnpoint
            # and keep the current spawnpoint
            if currentPoint.split(' ')[0:3] == convertedPoint.split(' ')[0:3]:
                convertedSpawnPoints.remove(convertedPoint)

    # Combine the converted spawnpoints with the current ones
    convertedSpawnPoints.extend(currentSpawnPoints)

    # Open the new spawnpoints file
    with newFilePath.open('w') as newFile:

        # Write the spawnpoints to the spawnpoints file
        newFile.writelines(convertedSpawnPoints)
示例#10
0
def write_spawnpoint_file(fileName, mapName, convertedSpawnPoints):
    # The name of the new spawnpoints file
    newFileName = mapName + '.txt'

    # The path to the new spawnpoints file
    newFilePath = get_game_dir('/cfg/gungame51/spawnpoints/' + newFileName)

    # If the spawnpoints are being overwritten, or there are no current
    # spawnpoints, create an empty list for them
    if int(gg_convert) == 2 or not newFilePath.isfile():
        currentSpawnPoints = []

    # If there are current spawnpoints, save them in a list
    else:

        with newFilePath.open() as newFile:
            currentSpawnPoints = newFile.readlines()

    # Copy the converted spawnpoints so that we can remove the original
    # converted spawnpoints during the for loop iteration
    convertedSpawnPoints_copy = convertedSpawnPoints[:]

    # For every current spawnpoint
    for currentPoint in currentSpawnPoints:

        # For every converted spawnpoint
        for convertedPoint in convertedSpawnPoints_copy:

            # If the x, y and z are equal, remove the converted spawnpoint
            # and keep the current spawnpoint
            if currentPoint.split(' ')[0:3] == convertedPoint.split(' ')[0:3]:
                convertedSpawnPoints.remove(convertedPoint)

    # Combine the converted spawnpoints with the current ones
    convertedSpawnPoints.extend(currentSpawnPoints)

    # Open the new spawnpoints file
    with newFilePath.open('w') as newFile:

        # Write the spawnpoints to the spawnpoints file
        newFile.writelines(convertedSpawnPoints)
示例#11
0
def loadSpawnFile(mapName):
    global spawnPoints
    global pointsLoaded

    spawnPoints = []
    pointsLoaded = False

    # Get spawnpoint file
    spawnFile = get_game_dir('cfg/gungame51/spawnpoints/%s.txt' % mapName)

    # Does the file exist?
    if not spawnFile.isfile():
        return

    # Get spawnpoint lines
    with spawnFile.open() as spawnPointFile:
        fileLines = [x.strip() for x in spawnPointFile.readlines()]

    # Set up spawnpoints
    spawnPoints = [x.split(' ', 6) for x in fileLines]

    # Randomize spawnpoints
    random.shuffle(spawnPoints)
示例#12
0
def loadSpawnFile(mapName):
    global spawnPoints
    global pointsLoaded

    spawnPoints = []
    pointsLoaded = False

    # Get spawnpoint file
    spawnFile = get_game_dir('cfg/gungame51/spawnpoints/%s.txt' % mapName)

    # Does the file exist?
    if not spawnFile.isfile():
        return

    # Get spawnpoint lines
    with spawnFile.open() as spawnPointFile:
        fileLines = [x.strip() for x in spawnPointFile.readlines()]

    # Set up spawnpoints
    spawnPoints = [x.split(' ', 6) for x in fileLines]

    # Randomize spawnpoints
    random.shuffle(spawnPoints)
示例#13
0
# GunGame Imports
from gungame51.core import get_game_dir
from gungame51.core import in_map
#   Messaging
from gungame51.core.messaging.shortcuts import langstring

# =============================================================================
# >> GLOBALS
# =============================================================================
# Get the es.ServerVar() instance of "gg_dynamic_chattime"
gg_dynamic_chattime = es.ServerVar("gg_dynamic_chattime")
# Get the es.ServerVar() instance of "mp_chattime"
mp_chattime = es.ServerVar("mp_chattime")

soundDir = get_game_dir('sound')
iniDir = get_game_dir('cfg/gungame51/sound_packs')

# winnerSounds stores a shuffled list of winner sounds to come if random winner
# sounds is enabled
winnerSounds = []
# defaultChatTime stores the default mp_chattime for gg_dynamic_chattime to use
# if it cannot check the length of the winner sound
defaultChatTime = -1


# =============================================================================
# >> CLASSES
# =============================================================================
class SoundPack(object):
    def __init__(self, name):
示例#14
0
$LastChangedBy: satoon101 $
$LastChangedDate: 2012-01-23 13:23:59 -0500 (Mon, 23 Jan 2012) $
"""

# =============================================================================
# >> IMPORTS
# =============================================================================
# GunGame Imports
from gungame51.core import get_game_dir


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Store the path to the scripts directory
_main_addon_path = get_game_dir("addons/eventscripts/gungame51/scripts")


# =============================================================================
# >> CLASSES
# =============================================================================
class _ValidAddons(dict):
    """Class used to get/store all valid addons and their type"""

    def __init__(self):
        """Gets all addons if the class has not already be initialized"""

        # Store the included addons
        self.included = self._get_addons_by_type("included")

        # Store the custom addons
示例#15
0
# =============================================================================
# >> ADDON REGISTRATION/INFORMATION
# =============================================================================
info = AddonInfo()
info.name = 'gg_convert'
info.title = 'GG Welcome Message'
info.author = 'GG Dev Team'
info.version = "5.1.%s" % "$Rev: 571 $".split('$Rev: ')[1].split()[0]

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
gg_convert = es.ServerVar('gg_convert')
# The path to the directory from which we convert
convertDir = get_game_dir('cfg/gungame51/converter')
# An instance of the Database() class to adjust the winners database with
ggDB = Database()


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    # Check for files to convert and run the conversion
    run_conversion()


# =============================================================================
# >> GAME EVENTS
# =============================================================================
示例#16
0
# =============================================================================
# >> ADDON REGISTRATION/INFORMATION
# =============================================================================
info = AddonInfo()
info.name = 'gg_convert'
info.title = 'GG Welcome Message'
info.author = 'GG Dev Team'
info.version = "5.1.%s" % "$Rev: 571 $".split('$Rev: ')[1].split()[0]

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
gg_convert = es.ServerVar('gg_convert')
# The path to the directory from which we convert
convertDir = get_game_dir('cfg/gungame51/converter')
# An instance of the Database() class to adjust the winners database with
ggDB = Database()


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    # Check for files to convert and run the conversion
    run_conversion()


# =============================================================================
# >> GAME EVENTS
# =============================================================================
示例#17
0
$Rev: 617 $
$LastChangedBy: satoon101 $
$LastChangedDate: 2012-01-23 13:23:59 -0500 (Mon, 23 Jan 2012) $
'''

# =============================================================================
# >> IMPORTS
# =============================================================================
# GunGame Imports
from gungame51.core import get_game_dir

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Store the path to the scripts directory
_main_addon_path = get_game_dir('addons/eventscripts/gungame51/scripts')


# =============================================================================
# >> CLASSES
# =============================================================================
class _ValidAddons(dict):
    '''Class used to get/store all valid addons and their type'''
    def __init__(self):
        '''Gets all addons if the class has not already be initialized'''

        # Store the included addons
        self.included = self._get_addons_by_type('included')

        # Store the custom addons
        # Make sure that each addon is only listed once
示例#18
0
 def connect(self):
     self._ggSQL = connect(get_game_dir(
                 'cfg/gungame51/database/gg_database.db'))
     self.curs = self._ggSQL.cursor()
示例#19
0
gg_map_vote_rtv_command = es.ServerVar("gg_map_vote_rtv_command")
gg_map_vote_rtv_levels_required = es.ServerVar("" + "gg_map_vote_rtv_levels_required")
gg_map_vote_rtv_percent = es.ServerVar("gg_map_vote_rtv_percent")
gg_map_vote_nominate = es.ServerVar("gg_map_vote_nominate")
gg_map_vote_nominate = es.ServerVar("gg_map_vote_nominate")
gg_map_vote_nominate_command = es.ServerVar("gg_map_vote_nominate_command")

eventscripts_currentmap = es.ServerVar("eventscripts_currentmap")
eventscripts_maphandler = es.ServerVar("eventscripts_maphandler")

# Player command backup var
player_command_backup = str(gg_map_vote_player_command)

# Dictionary to store the location of the source of the map files
dict_mapListSource = {
    1: get_game_dir("mapcycle.txt"),
    2: get_game_dir("maplist.txt"),
    3: get_game_dir(
        str(gg_map_vote_file) + ".txt" if not str(gg_map_vote_file).endswith(".txt") else str(gg_map_vote_file)
    ),
    4: get_game_dir("maps"),
}

# List to store the maps previously voted for "gg_map_vote_dont_show_last_maps"
list_lastMaps = []

# Store the players that have already voted
votedUserids = set()

# Holds options and the userids that voted for them
mapVoteOptions = {}
示例#20
0
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Server Vars
spe_version_var = es.ServerVar('spe_version')
eventscripts_ver = es.ServerVar('eventscripts_ver')
es_corelib_ver = es.ServerVar('es_corelib_ver')
ip = es.ServerVar('ip')
port = es.ServerVar('hostport')
metamod_version = es.ServerVar('metamod_version')
sourcemod_version = es.ServerVar('sourcemod_version')
mani_admin_plugin_version = es.ServerVar('mani_admin_plugin_version')
est_version = es.ServerVar('est_version')

# Other vars
file_name = get_game_dir('cfg/gungame51/logs' + '/GunGame%s_Log.txt' %
                         gungame_info('version').replace('.', '_'))

file_created = False

OS = get_os()


# =============================================================================
# >> TRACEBACK EVENT
# =============================================================================
def gungame_except_hook(tb_type, value, trace_back, mute_console=False):
    # If this error was called to stop an attribute from being set, do not log
    # it.
    if str(value) == "gg_cancel_callback":
        return
示例#21
0
def make_log_file():
    # Log file header
    header = [
        '*' * 79 + '\n', '*' + ' ' * 77 + '*\n',
        '*' + 'GUNGAME v5.1 ERROR LOGGING'.center(77) + '*' + '\n',
        '*' + 'HTTP://FORUMS.GUNGAME.NET/'.center(77) + '*\n',
        '*' + ' ' * 77 + '*\n',
        ('*' + 'GG VERSION: '.rjust(19) + gungame_info('version').ljust(19) +
         'IP: '.rjust(19) + str(ip).upper().ljust(15) + ' ' * 5 + '*\n'),
        ('*' + 'SPE VERSION: '.rjust(19) + str(spe_version_var).ljust(19) +
         'PORT: '.rjust(19) + str(port).ljust(15) + ' ' * 5 + '*\n'),
        ('*' + 'PLATFORM: '.rjust(19) + str(OS).upper().ljust(19) +
         'DATE: '.rjust(19) + strftime('%m-%d-%Y').ljust(15) + ' ' * 5 +
         '*\n'),
        ('*' + 'ES VERSION: '.rjust(19) + str(eventscripts_ver).ljust(19) +
         'ES CORE VERSION: '.rjust(19) + str(es_corelib_ver).ljust(15) +
         ' ' * 5 + '*\n'),
        ('*' + 'MM VERSION: '.rjust(19) + str(metamod_version).ljust(19) +
         'SM VERSION: '.rjust(19) + str(sourcemod_version).ljust(15) +
         ' ' * 5 + '*\n'),
        ('*' + 'MANI VERSION: '.rjust(19) +
         str(mani_admin_plugin_version).ljust(19) + 'EST VERSION: '.rjust(19) +
         str(est_version).ljust(15) + ' ' * 5 + '*\n'), '*' + ' ' * 77 + '*\n',
        '*' * 79 + '\n', '\n', '\n'
    ]

    # Does the file allready exists ?
    if file_name.isfile():

        # Read the file
        with file_name.open() as log_file:

            readlines = log_file.readlines()

        # Does the header match ?
        for i in range(len(header)):
            if readlines[i] != header[i]:
                if i == 7 and header[7][20:39] == readlines[7][20:39]:
                    continue
                break

        # Header matched, use this file
        else:
            return

        # Find a new file name for the old file
        n = 0

        while True:
            n += 1
            new_file_name = (
                get_game_dir('cfg/gungame51/logs') +
                '/GunGame%s' % gungame_info('version').replace('.', '_') +
                '_Log_Old[%01i].txt' % n)
            if not new_file_name.isfile():
                break

        # Make new file w/ old errors
        with new_file_name.open('w') as log_file:
            log_file.writelines(readlines)

    # Start new log file
    with file_name.open('w') as log_file:
        log_file.writelines(header)

    global file_created
    file_created = True
示例#22
0
# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Server Vars
spe_version_var = es.ServerVar('spe_version')
eventscripts_ver = es.ServerVar('eventscripts_ver')
es_corelib_ver = es.ServerVar('es_corelib_ver')
ip = es.ServerVar('ip')
port = es.ServerVar('hostport')
metamod_version = es.ServerVar('metamod_version')
sourcemod_version = es.ServerVar('sourcemod_version')
mani_admin_plugin_version = es.ServerVar('mani_admin_plugin_version')
est_version = es.ServerVar('est_version')

# Other vars
file_name = get_game_dir('cfg/gungame51/logs' +
              '/GunGame%s_Log.txt' % gungame_info('version').replace('.', '_'))

file_created = False

OS = get_os()


# =============================================================================
# >> TRACEBACK EVENT
# =============================================================================
def gungame_except_hook(tb_type, value, trace_back, mute_console=False):
    # If this error was called to stop an attribute from being set, do not log
    # it.
    if str(value) == "gg_cancel_callback":
        return
示例#23
0
def make_log_file():
    # Log file header
    header = ['*' * 79 + '\n', '*' + ' ' * 77 + '*\n',
              '*' + 'GUNGAME v5.1 ERROR LOGGING'.center(77) + '*' + '\n',
              '*' + 'HTTP://FORUMS.GUNGAME.NET/'.center(77) + '*\n',
              '*' + ' ' * 77 + '*\n',
              ('*' + 'GG VERSION: '.rjust(19) +
                gungame_info('version').ljust(19) + 'IP: '.rjust(19) +
                str(ip).upper().ljust(15) + ' ' * 5 + '*\n'),
              ('*' + 'SPE VERSION: '.rjust(19) +
                str(spe_version_var).ljust(19) +
                'PORT: '.rjust(19) + str(port).ljust(15) + ' ' * 5 + '*\n'),
              ('*' + 'PLATFORM: '.rjust(19) + str(OS).upper().ljust(19) +
                'DATE: '.rjust(19) + strftime('%m-%d-%Y').ljust(15) +
                ' ' * 5 + '*\n'), ('*' + 'ES VERSION: '.rjust(19) +
               str(eventscripts_ver).ljust(19) +
               'ES CORE VERSION: '.rjust(19) + str(es_corelib_ver).ljust(15) +
               ' ' * 5 + '*\n'), ('*' + 'MM VERSION: '.rjust(19) +
               str(metamod_version).ljust(19) + 'SM VERSION: '.rjust(19) +
               str(sourcemod_version).ljust(15) + ' ' * 5 + '*\n'),
               ('*' + 'MANI VERSION: '.rjust(19) +
               str(mani_admin_plugin_version).ljust(19) +
               'EST VERSION: '.rjust(19) + str(est_version).ljust(15) +
               ' ' * 5 + '*\n'),
               '*' + ' ' * 77 + '*\n', '*' * 79 + '\n', '\n', '\n']

    # Does the file allready exists ?
    if file_name.isfile():

        # Read the file
        with file_name.open() as log_file:

            readlines = log_file.readlines()

        # Does the header match ?
        for i in range(len(header)):
            if readlines[i] != header[i]:
                if i == 7 and header[7][20:39] == readlines[7][20:39]:
                    continue
                break

        # Header matched, use this file
        else:
            return

        # Find a new file name for the old file
        n = 0

        while True:
            n += 1
            new_file_name = (get_game_dir('cfg/gungame51/logs') +
                '/GunGame%s' % gungame_info('version').replace('.', '_') +
                '_Log_Old[%01i].txt' % n)
            if not new_file_name.isfile():
                break

        # Make new file w/ old errors
        with new_file_name.open('w') as log_file:
            log_file.writelines(readlines)

    # Start new log file
    with file_name.open('w') as log_file:
        log_file.writelines(header)

    global file_created
    file_created = True
示例#24
0
from path import path

# EventScripts Imports
import es
from weaponlib import getWeaponList

# GunGame Imports
from gungame51.core import get_game_dir
from gungame51.core.messaging.shortcuts import langstring


# =============================================================================
# >> GLOBALS
# =============================================================================
# Paths/Files
weaponOrdersPath = get_game_dir('cfg/gungame51/weapon_orders/')
weaponOrderFilesTXT = weaponOrdersPath.files("*.txt")
#weaponOrderFilesINI = weaponOrdersPath.files("*.ini")

# Variables
gg_multikill_override = es.ServerVar('gg_multikill_override')
gg_weapon_order_sort_type = es.ServerVar('gg_weapon_order_sort_type')

# Weapons
VALID_WEAPONS = (getWeaponList('#primary') + getWeaponList('#secondary') +
                ['weapon_hegrenade', 'weapon_knife'])


# =============================================================================
# >> CLASSES
# =============================================================================
示例#25
0
def load():

    # Create the cfg file
    with ConfigContextManager(
      path(__file__).parent.split('scripts')[~0][1:]) as config:

        # Create the gg_warmup_round instance
        with config.cfg_cvar('gg_warmup_round') as cvar:

            cvar.name = 'WARMUP ROUND'
            cvar.notes.append('Players cannot ' +
                'level up during the warmup round.')
            cvar.notes.append('Warmup round is triggered ' +
                'at the start of each map change.')
            cvar.options.append('0 = Disabled.')
            cvar.options.append('1 = Enabled.')
            cvar.default = 0
            cvar.text = 'Enables or disables warmupround.'

        # Create the gg_warmup_timer instance
        with config.cfg_cvar('gg_warmup_timer') as cvar:

            cvar.name = 'WARMUP ROUND TIMER'
            cvar.options.append('The amount of time (in ' +
                'seconds) that the warmup round will last.')
            cvar.default = 30
            cvar.text = ('The amount of time (in ' +
                'seconds) that the the warmup round will last.')

        # Create the gg_warmup_weapon instance
        with config.cfg_cvar('gg_warmup_weapon') as cvar:

            cvar.name = 'WARMUP ROUND WEAPON'
            cvar.notes.append('Only supports "weapon_*" entities.')
            cvar.notes.append('Warmup round is triggered at ' +
                'the start of each map change.')
            cvar.options.append(' awp   \tscout\taug   \tmac10' +
                '\ttmp   \tmp5navy\tump45\tp90')
            cvar.options.append(' galil\tfamas\tak47\tsg552\t' +
                'sg550\tg3sg1\tm249\tm3')
            cvar.options.append(' xm1014\tm4a1\tglock\tusp   ' +
                '\tp228\tdeagle\telite\tfiveseven')
            cvar.options.append(' hegrenade\tknife')
            cvar.options.append('')
            cvar.options.append(' 0 = The first level weapon')
            cvar.options.append(' weapon1,weapon2,weapon3 = For ' +
                'each warmup, one of these weapons is chosen')
            cvar.options.append(' #random = For ' +
                'each warmup, a random weapon is chosen.')
            cvar.default = 'hegrenade'
            cvar.text = ('The weapon that players ' +
                'will use during the warmup round.')

        # Create the cfg section
        config.cfg_section('WARMUP START AND END CFG SETTINGS')

        # Create the gg_warmup_start_file instance
        with config.cfg_cvar('gg_warmup_start_file') as cvar:

            cvar.name = 'WARMUP ROUND START CFG FILE'
            cvar.description.append('Set to the .cfg ' +
                'file to be executed when Warmup Round starts.')
            cvar.notes.append('The cfg file should contain the ' +
                'GunGame values you wish to use for the current map.')
            cvar.notes.append('Make sure to turn off addons that should ' +
                'not be used during Warmup Round "prior" to turning on ' +
                'any addons that should be used during Warmup Round.')
            cvar.notes.append('The path to the file "must" ' +
                'be relative to the "../cfg/gungame51/" folder')
            cvar.default = (
                'included_addon_configs/warmup_round_start_default')
            cvar.text = 'CFG file to be executed when Warmup Round starts.'

        # Create the gg_warmup_end_file instance
        with config.cfg_cvar('gg_warmup_end_file') as cvar:

            cvar.name = 'WARMUP ROUND END CFG FILE'
            cvar.description.append('Set to the .cfg ' +
                'file to be executed when Warmup Round ends.')
            cvar.notes.append('The cfg file should contain the ' +
                'GunGame values you wish to use for the current map.')
            cvar.notes.append('Make sure to turn off any addons that ' +
                'were used during Warmup Round and are not needed for ' +
                'the current match, "prior" to turning on any addons ' +
                'that are needed for the current match.')
            cvar.notes.append('The path to the file "must" ' +
                'be relative to the "../cfg/gungame51/" folder')
            cvar.default = (
                'included_addon_configs/warmup_round_end_default')
            cvar.text = 'CFG file to be executed when Warmup Round ends.'

        # Create the extension section
        config.cfg_section('WARMUP ROUND EXTENSION SETTINGS')

        with config.cfg_cvar('gg_warmup_round_min_players') as cvar:

            cvar.name = 'MINUMUM HUMAN PLAYERS'
            cvar.description.append('Set to the minimum ' +
                'number of players needed for Warmup Round to end.')
            cvar.default = 0
            cvar.text = (
                'Number of human players needed for Warmup Round to end.')

        with config.cfg_cvar('gg_warmup_round_max_extensions') as cvar:

            cvar.name = 'MAX EXTENSIONS'
            cvar.description.append('Number of extensions '
                'allowed before Warmup Round automatically ends.')
            cvar.default = 1
            cvar.text = ('Maximum number of '
                'extensions allowed before Warmup Round ends.')

        with config.cfg_cvar('gg_warmup_round_players_reached') as cvar:

            cvar.name = 'MIN HUMAN PLAYERS REACHED'
            cvar.description.append(
                'Determines whether or not to end Warmup Round ' +
                'when the minimum number of players has been reached.')
            cvar.options.append(
                '0 = Never end Warmup as soon as min players is reached.')
            cvar.options.append('1 = Only end Warmup ' +
                'if in "extended" time when min players is reached.')
            cvar.options.append(
                '2 = End Warmup Round as soon as min players is reached.')
            cvar.default = 0
            cvar.text = (
                'Allows Warmup Round to end when min players is reached.')

    # Get the path to the default Warmup Round Start cfg file
    start_path = path(get_game_dir(
        'cfg/gungame51/included_addon_configs/warmup_round_start_default.cfg'))

    # Does the file exist?
    if not start_path.isfile():

        # Create the AddonCFG instance
        start = AddonCFG(start_path)

        # Add basic description of how to use the file
        start.text('-' * 74 + '//')
        start.text('//'.rjust(76))
        start.text('warmup_round_start_default.cfg'.center(74) + '//')
        start.text('//'.rjust(76))
        start.text(('This is the default file (using the ' +
            'value of gg_warmup_start_file)').center(74) + '//')
        start.text(('used to determine the gameplay ' +
            '"during" Warmup Round').center(74) + '//')
        start.text('//'.rjust(76))
        start.text(('As an example, if the server should ' +
            'have gg_deathmatch during Warmup').center(74) + '//')
        start.text(('and gg_elimination, gg_turbo, and ' +
            'gg_teamwork for the actual match,').center(74) + '//')
        start.text(
            'the contents could look like the following'.center(74) + '//')
        start.text('//'.rjust(76))
        start.text((' // Turn off any addons that ' +
            'should not be ran during warmup').ljust(74) + '//')
        start.text(' gg_elimination 0'.ljust(74) + '//')
        start.text(' gg_turbo 0'.ljust(74) + '//')
        start.text(' gg_teamwork 0'.ljust(74) + '//')
        start.text('//'.rjust(76))
        start.text((' // Turn on any addons that ' +
            'should be ran during warmup').ljust(74) + '//')
        start.text(' gg_deathmatch 1'.ljust(74) + '//')
        start.text('//'.rjust(76))
        start.text('-' * 74 + '//')

        # Write the file
        start.write()

    # Get the path to the default Warmup Round End cfg file
    end_path = path(get_game_dir(
        'cfg/gungame51/included_addon_configs/warmup_round_end_default.cfg'))

    # Does the file exist?
    if not end_path.isfile():

        # Create the AddonCFG instance
        end = AddonCFG(end_path)

        # Add basic description of how to use the file
        end.text('-' * 74 + '//')
        end.text('//'.rjust(76))
        end.text('warmup_round_end_default.cfg'.center(74) + '//')
        end.text('//'.rjust(76))
        end.text(('This is the default file (using the ' +
            'value of gg_warmup_end_file)').center(74) + '//')
        end.text(('used to change the gameplay from ' +
            'Warmup to the actual match').center(74) + '//')
        end.text('//'.rjust(76))
        end.text(('As an example, if the server should ' +
            'have gg_deathmatch during Warmup').center(74) + '//')
        end.text(('and gg_elimination, gg_turbo, and ' +
            'gg_teamwork for the actual match,').center(74) + '//')
        end.text(
            'the contents could look like the following'.center(74) + '//')
        end.text('//'.rjust(76))
        end.text((' // Turn off any addons that ' +
            'were ran during warmup,').ljust(74) + '//')
        end.text(' //   but need to be off during the match'.ljust(74) + '//')
        end.text(' gg_deathmatch 0'.ljust(74) + '//')
        end.text('//'.rjust(76))
        end.text((' // Turn on any addons that ' +
            'should be ran for the match').ljust(74) + '//')
        end.text(' gg_elimination 1'.ljust(74) + '//')
        end.text(' gg_turbo 1'.ljust(74) + '//')
        end.text(' gg_teamwork 1'.ljust(74) + '//')
        end.text('//'.rjust(76))
        end.text('-' * 74 + '//')

        # Write the file
        end.write()
示例#26
0
 def connect(self):
     self._ggSQL = connect(
         get_game_dir('cfg/gungame51/database/gg_database.db'))
     self.curs = self._ggSQL.cursor()
示例#27
0
# GunGame Imports
from gungame51.core import get_game_dir
from gungame51.core import in_map
#   Messaging
from gungame51.core.messaging.shortcuts import langstring


# =============================================================================
# >> GLOBALS
# =============================================================================
# Get the es.ServerVar() instance of "gg_dynamic_chattime"
gg_dynamic_chattime = es.ServerVar("gg_dynamic_chattime")
# Get the es.ServerVar() instance of "mp_chattime"
mp_chattime = es.ServerVar("mp_chattime")

soundDir = get_game_dir('sound')
iniDir = get_game_dir('cfg/gungame51/sound_packs')

# winnerSounds stores a shuffled list of winner sounds to come if random winner
# sounds is enabled
winnerSounds = []
# defaultChatTime stores the default mp_chattime for gg_dynamic_chattime to use
# if it cannot check the length of the winner sound
defaultChatTime = -1


# =============================================================================
# >> CLASSES
# =============================================================================
class SoundPack(object):
    def __init__(self, name):
示例#28
0
    '' + 'gg_map_vote_rtv_levels_required')
gg_map_vote_rtv_percent = es.ServerVar('gg_map_vote_rtv_percent')
gg_map_vote_nominate = es.ServerVar('gg_map_vote_nominate')
gg_map_vote_nominate = es.ServerVar('gg_map_vote_nominate')
gg_map_vote_nominate_command = es.ServerVar('gg_map_vote_nominate_command')

eventscripts_currentmap = es.ServerVar('eventscripts_currentmap')
eventscripts_maphandler = es.ServerVar('eventscripts_maphandler')

# Player command backup var
player_command_backup = str(gg_map_vote_player_command)

# Dictionary to store the location of the source of the map files
dict_mapListSource = {
    1:
    get_game_dir('mapcycle.txt'),
    2:
    get_game_dir('maplist.txt'),
    3:
    get_game_dir(
        str(gg_map_vote_file) + '.txt' if
        not str(gg_map_vote_file).endswith('.txt') else str(gg_map_vote_file)),
    4:
    get_game_dir('maps')
}

# List to store the maps previously voted for "gg_map_vote_dont_show_last_maps"
list_lastMaps = []

# Store the players that have already voted
votedUserids = set()