# ==============================================================================
# IMPORTS
# ==============================================================================
# Python Imports
import os
import sys
import random
# EventScripts Imports
import es
import gamethread
import playerlib
import usermsg
import popuplib
import keyvalues
from configobj import ConfigObj
# ==============================================================================
# ADDON REGISTRATION
# ==============================================================================
# Version info
__version__ = '5.0.585'
es.ServerVar('eventscripts_gg', __version__).makepublic()
es.ServerVar('eventscripts_gg5', __version__).makepublic()
# Register with EventScripts
info = es.AddonInfo()
info.name = 'GunGame5'
info.version = __version__
info.url = 'http://gungame5.com/'
info.basename = 'gungame'
info.author = 'Michael Barr (XE_ManUp), Paul (RideGuy), Saul Rennison'
# ==============================================================================
# LOAD GUNGAMELIB
# ==============================================================================
import gungamelib
reload(gungamelib)
# ==============================================================================
# GLOBALS
# ==============================================================================
dict_variables = {}
list_includedAddonsDir = []
list_customAddonsDir = []
list_stripExceptions = []
def load():
# Load translation file for gungame
gungamelib.loadTranslations('gungame')
# Exec server.cfg before gungame loads. If gungame is loaded from autoexec
# this is needed so that the correct values are stored.
es.server.cmd('exec server.cfg')
try:
initialize()
except:
gungamelib.echo('gungame', 0, 0, 'Load_Exception')
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
es.excepter(*sys.exc_info())
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
es.unload('gungame')
def initialize():
global countBombDeathAsSuicide
global list_stripExceptions
# Register addon
gungame = gungamelib.registerAddon('gungame')
gungame.setDisplayName('GunGame')
# Print load started
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
gungamelib.echo('gungame', 0, 0, 'Load_Start', {'version': __version__})
# Load custom events
es.loadevents('declare', 'addons/eventscripts/gungame/events/es_gungame_events.res')
# Loop through included addons
# NOTE TO DEVS: Move this over to gungamelib?
for includedAddon in os.listdir(gungamelib.getGameDir('addons/eventscripts/gungame/included_addons/')):
if includedAddon[:3] == 'gg_':
list_includedAddonsDir.append(includedAddon)
# Loop through custom addons
# NOTE TO DEVS: Move this over to gungamelib?
for customAddon in os.listdir(gungamelib.getGameDir('addons/eventscripts/gungame/custom_addons/')):
if customAddon[:3] == 'gg_':
list_customAddonsDir.append(customAddon)
# Load configs
gungamelib.echo('gungame', 0, 0, 'Load_Configs')
gungamelib.getConfig('gg_en_config.cfg')
gungamelib.getConfig('gg_default_addons.cfg')
gungamelib.getConfig('gg_map_vote.cfg')
# Execute addon configs
gungamelib.echo('gungame', 0, 0, 'Load_CustomConfigs')
for addon in list_customAddonsDir:
gungamelib.echo('gungame', 0, 0, 'ExecuteCustomConfig', {'addon': addon})
gungamelib.getConfig('custom_addon_configs/%s.cfg' % addon)
# Fire the gg_server.cfg
es.server.cmd('exec gungame5/gg_server.cfg')
gungamelib.echo('gungame', 0, 0, 'Load_Commands')
# Register commands
gungame.registerPublicCommand('weapons', gungamelib.sendWeaponOrderMenu)
# Clear out the GunGame system
gungamelib.resetGunGame()
# Set Up a custom variable for voting in dict_variables
dict_variables['gungame_voting_started'] = False
# Set up a custom variable for tracking multi-rounds
dict_variables['roundsRemaining'] = gungamelib.getVariableValue('gg_multi_round')
gungamelib.echo('gungame', 0, 0, 'Load_Warmup')
# Load sound pack
gungamelib.echo('gungame', 0, 0, 'Load_SoundSystem')
gungamelib.getSoundPack(gungamelib.getVariableValue('gg_soundpack'))
# Print load completed
gungamelib.echo('gungame', 0, 0, 'Load_Completed')
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
def unload():
global gungameWeaponOrderMenu
# Unload all enabled addons
for addonName in gungamelib.getRegisteredAddonList():
if addonName in list_includedAddonsDir:
es.unload('gungame/included_addons/%s' % addonName)
elif addonName in list_customAddonsDir:
es.unload('gungame/custom_addons/%s' % addonName)
# Enable Buyzones
userid = es.getuserid()
es.server.queuecmd('es_xfire %d func_buyzone Enable' % userid)
# Get map if
try:
mapObjectives = gungamelib.getVariableValue('gg_map_obj')
# Re-enable objectives
if mapObjectives < 3:
# Re-enable all objectives
if mapObjectives == 0:
if len(es.createentitylist('func_bomb_target')):
es.server.queuecmd('es_xfire %d func_bomb_target Enable' %userid)
elif len(es.createentitylist('func_hostage_rescue')):
es.server.queuecmd('es_xfire %d func_hostage_rescue Enable' %userid)
# Enable bomb zone
elif mapObjectives == 1:
if len(es.createentitylist('func_bomb_target')):
es.server.queuecmd('es_xfire %d func_bomb_target Enable' %userid)
# Enable hostage objectives
elif mapObjectives == 2:
if len(es.createentitylist('func_hostage_rescue')):
es.server.queuecmd('es_xfire %d func_hostage_rescue Enable' %userid)
except:
pass
# Fire gg_unload event
es.event('initialize', 'gg_unload')
es.event('fire', 'gg_unload')
# Remove the notify flag from all GunGame Console Variables
list_gungameVariables = gungamelib.getVariableList()
for variable in list_gungameVariables:
es.ServerVar(variable).removeFlag('notify')
es.server.cmd('%s 0' % variable)
# Unregister this addon
gungamelib.unregisterAddon('gungame')
gungamelib.clearGunGame()
def es_map_start(event_var):
dict_variables['gungame_voting_started'] = False
# ==================
# VOTE TRIGGER CHECK
# ==================
if es.ServerVar('mp_timelimit') == 3:
# Nextmap already set?
if es.ServerVar('eventscripts_nextmapoverride') != '':
gungamelib.echo('gungame', 0, 0, 'MapSetBefore')
return
# Vote already started?
if dict_variables['gungame_voting_started']:
return
else:
es.event('initialize', 'gg_vote')
es.event('fire', 'gg_vote')
def gg_vote(event_var):
dict_variables['gungame_voting_started'] = True
if gungamelib.getVariableValue('gg_map_vote') == 2:
es.server.queuecmd(gungamelib.getVariableValue('gg_map_vote_command'))
def server_cvar(event_var):
cvarName = event_var['cvarname']
newValue = event_var['cvarvalue']
# GG_MAPVOTE
if cvarName == 'gg_map_vote':
if newValue == 1 and 'gg_map_vote' not in gungamelib.getRegisteredAddonList():
es.server.queuecmd('es_load gungame/included_addons/gg_map_vote')
elif newValue != 1 and 'gg_map_vote' in gungamelib.getRegisteredAddonList():
es.unload('gungame/included_addons/gg_map_vote')
# IMPORTS
# ==============================================================================
# Python Imports
import os
import sys
import random
# EventScripts Imports
import es
import gamethread
import playerlib
import usermsg
import popuplib
import keyvalues
from configobj import ConfigObj
# ==============================================================================
# ADDON REGISTRATION
# ==============================================================================
# Version info
__version__ = '5.0.585'
es.ServerVar('eventscripts_gg', __version__).makepublic()
es.ServerVar('eventscripts_gg5', __version__).makepublic()
# Register with EventScripts
info = es.AddonInfo()
info.name = 'GunGame5'
info.version = __version__
info.url = 'http://gungame5.com/'
info.basename = 'gungame'
info.author = 'Michael Barr (XE_ManUp), Paul (RideGuy), Saul Rennison'
# ==============================================================================
# LOAD GUNGAMELIB
# ==============================================================================
import gungamelib
reload(gungamelib)
# ==============================================================================
# GLOBALS
# ==============================================================================
dict_variables = {}
list_includedAddonsDir = []
list_customAddonsDir = []
list_stripExceptions = []
def load():
# Load translation file for gungame
gungamelib.loadTranslations('gungame')
# Exec server.cfg before gungame loads. If gungame is loaded from autoexec
# this is needed so that the correct values are stored.
es.server.cmd('exec server.cfg')
try:
initialize()
except:
gungamelib.echo('gungame', 0, 0, 'Load_Exception')
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
es.excepter(*sys.exc_info())
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
es.unload('gungame')
def initialize():
global countBombDeathAsSuicide
global list_stripExceptions
# Register addon
gungame = gungamelib.registerAddon('gungame')
gungame.setDisplayName('GunGame')
# Print load started
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
gungamelib.echo('gungame', 0, 0, 'Load_Start', {'version': __version__})
# Load custom events
es.loadevents('declare', 'addons/eventscripts/gungame/events/es_gungame_events.res')
# Loop through included addons
# NOTE TO DEVS: Move this over to gungamelib?
for includedAddon in os.listdir(gungamelib.getGameDir('addons/eventscripts/gungame/included_addons/')):
if includedAddon[:3] == 'gg_':
list_includedAddonsDir.append(includedAddon)
# Loop through custom addons
# NOTE TO DEVS: Move this over to gungamelib?
for customAddon in os.listdir(gungamelib.getGameDir('addons/eventscripts/gungame/custom_addons/')):
if customAddon[:3] == 'gg_':
list_customAddonsDir.append(customAddon)
# Load configs
gungamelib.echo('gungame', 0, 0, 'Load_Configs')
gungamelib.getConfig('gg_en_config.cfg')
gungamelib.getConfig('gg_default_addons.cfg')
gungamelib.getConfig('gg_map_vote.cfg')
# Execute addon configs
gungamelib.echo('gungame', 0, 0, 'Load_CustomConfigs')
for addon in list_customAddonsDir:
gungamelib.echo('gungame', 0, 0, 'ExecuteCustomConfig', {'addon': addon})
gungamelib.getConfig('custom_addon_configs/%s.cfg' % addon)
# Fire the gg_server.cfg
es.server.cmd('exec gungame5/gg_server.cfg')
gungamelib.echo('gungame', 0, 0, 'Load_Commands')
# Register commands
gungame.registerPublicCommand('weapons', gungamelib.sendWeaponOrderMenu)
# Clear out the GunGame system
gungamelib.resetGunGame()
# Set Up a custom variable for voting in dict_variables
dict_variables['gungame_voting_started'] = False
# Set up a custom variable for tracking multi-rounds
dict_variables['roundsRemaining'] = gungamelib.getVariableValue('gg_multi_round')
gungamelib.echo('gungame', 0, 0, 'Load_Warmup')
# Load sound pack
gungamelib.echo('gungame', 0, 0, 'Load_SoundSystem')
gungamelib.getSoundPack(gungamelib.getVariableValue('gg_soundpack'))
# Print load completed
gungamelib.echo('gungame', 0, 0, 'Load_Completed')
es.dbgmsg(0, '[GunGame] %s' % ('=' * 80))
def unload():
global gungameWeaponOrderMenu
# Unload all enabled addons
for addonName in gungamelib.getRegisteredAddonList():
if addonName in list_includedAddonsDir:
es.unload('gungame/included_addons/%s' % addonName)
elif addonName in list_customAddonsDir:
es.unload('gungame/custom_addons/%s' % addonName)
# Enable Buyzones
userid = es.getuserid()
es.server.queuecmd('es_xfire %d func_buyzone Enable' % userid)
# Get map if
try:
mapObjectives = gungamelib.getVariableValue('gg_map_obj')
# Re-enable objectives
if mapObjectives < 3:
# Re-enable all objectives
if mapObjectives == 0:
if len(es.createentitylist('func_bomb_target')):
es.server.queuecmd('es_xfire %d func_bomb_target Enable' %userid)
elif len(es.createentitylist('func_hostage_rescue')):
es.server.queuecmd('es_xfire %d func_hostage_rescue Enable' %userid)
# Enable bomb zone
elif mapObjectives == 1:
if len(es.createentitylist('func_bomb_target')):
es.server.queuecmd('es_xfire %d func_bomb_target Enable' %userid)
# Enable hostage objectives
elif mapObjectives == 2:
if len(es.createentitylist('func_hostage_rescue')):
es.server.queuecmd('es_xfire %d func_hostage_rescue Enable' %userid)
except:
pass
# Fire gg_unload event
es.event('initialize', 'gg_unload')
es.event('fire', 'gg_unload')
# Remove the notify flag from all GunGame Console Variables
list_gungameVariables = gungamelib.getVariableList()
for variable in list_gungameVariables:
es.ServerVar(variable).removeFlag('notify')
es.server.cmd('%s 0' % variable)
# Unregister this addon
gungamelib.unregisterAddon('gungame')
gungamelib.clearGunGame()
def es_map_start(event_var):
dict_variables['gungame_voting_started'] = False
# ==================
# VOTE TRIGGER CHECK
# ==================
if es.ServerVar('mp_timelimit') == 3:
# Nextmap already set?
if es.ServerVar('eventscripts_nextmapoverride') != '':
gungamelib.echo('gungame', 0, 0, 'MapSetBefore')
return
# Vote already started?
if dict_variables['gungame_voting_started']:
return
else:
es.event('initialize', 'gg_vote')
es.event('fire', 'gg_vote')
def gg_vote(event_var):
dict_variables['gungame_voting_started'] = True
if gungamelib.getVariableValue('gg_map_vote') == 2:
es.server.queuecmd(gungamelib.getVariableValue('gg_map_vote_command'))
def server_cvar(event_var):
cvarName = event_var['cvarname']
newValue = event_var['cvarvalue']
# GG_MAPVOTE
if cvarName == 'gg_map_vote':
if newValue == 1 and 'gg_map_vote' not in gungamelib.getRegisteredAddonList():
es.server.queuecmd('es_load gungame/included_addons/gg_map_vote')
elif newValue != 1 and 'gg_map_vote' in gungamelib.getRegisteredAddonList():
es.unload('gungame/included_addons/gg_map_vote')
But it doesn't work. Does somebody know why doesn't this script work and what do I have to change?