def reCacheConnection(forceRecache=False):
    """
    Reconnect to the server to check for updates. This overwrites the cache.
    Sends version variables to the server to warn of any version issues for
    security updates, etc.

    @param bool forceRecache Whether or not it will ignore if the connection
                             already has a cache.
    """
    if not connection.hasCache() or forceRecache is True:
        data = {}
        data["eventscripts_ver"] = str(es.getString("eventscripts_ver"))
        data["es_corelib_ver"] = str(es.getString("es_corelib_ver"))
        data["eventscripts_ver_revision"] = str(es.getString("eventscripts_ver_revision"))
        data["eventscripts_xa"] = str(es.getString("eventscripts_xa"))
        data["os.name"] = os.name
        data["game"] = es.getGameName()
        data["hostport"] = str(es.getString("hostport"))
        try:
          l = es.getInt("hostip")
          data["hostip"] = '%d.%d.%d.%d' % (l>>24 & 255, l>>16 & 255, l>>8 & 255, l & 255)
        except:
          # oh well, skip the IP address
          es.dbgmsg(1, "es_checkversion: Couldn't get IP address properly")
          pass
        connection.data = data
        connection.connect()
        connection.reCacheUpdate()
        connection.disconnect()
예제 #2
0
def reCacheConnection(forceRecache=False):
    """
    Reconnect to the server to check for updates. This overwrites the cache.
    Sends version variables to the server to warn of any version issues for
    security updates, etc.

    @param bool forceRecache Whether or not it will ignore if the connection
                             already has a cache.
    """
    if not connection.hasCache() or forceRecache is True:
        data = {}
        data["eventscripts_ver"] = str(es.getString("eventscripts_ver"))
        data["es_corelib_ver"] = str(es.getString("es_corelib_ver"))
        data["eventscripts_ver_revision"] = str(
            es.getString("eventscripts_ver_revision"))
        data["eventscripts_xa"] = str(es.getString("eventscripts_xa"))
        data["os.name"] = os.name
        data["game"] = es.getGameName()
        data["hostport"] = str(es.getString("hostport"))
        try:
            l = es.getInt("hostip")
            data["hostip"] = '%d.%d.%d.%d' % (l >> 24 & 255, l >> 16 & 255,
                                              l >> 8 & 255, l & 255)
        except:
            # oh well, skip the IP address
            es.dbgmsg(1, "es_checkversion: Couldn't get IP address properly")
            pass
        connection.data = data
        connection.connect()
        connection.reCacheUpdate()
        connection.disconnect()
예제 #3
0
    def __init__(self, userid):

        self.userid = int(userid)
        self.gameName = es.getGameName()
        self.name = "sourcerpg_medic_user%s" % userid
        repeat.Repeat.__init__(self, self.name, self.healTeamates)
        repeat.dict_repeatInfo[self.name] = self
예제 #4
0
    def __init__(self, userid):

        self.userid   = int(userid)
        self.gameName = es.getGameName()
        self.name     = "sourcerpg_medic_user%s" % userid
        repeat.Repeat.__init__(self, self.name, self.healTeamates)
        repeat.dict_repeatInfo[self.name] = self
예제 #5
0
# ./addons/eventscripts/_libs/python/weaponlib.py

import es
from collections import deque

import psyco
psyco.full()

gamename = es.getGameName()


class WeaponManager(object):
    class Weapon(str):
        """ Represents weapons, returning property information and an uniform name """
        def __init__(self, name):
            str.__init__(self, name)
            self.info_name = name

        def setAttributes(self,
                          ammoprop='',
                          tags=(),
                          slot=0,
                          clip=0,
                          maxammo=0):
            self.info_ammoprop = ammoprop
            self.info_tags = (tags, ) if isinstance(tags, str) else tuple(tags)
            self.info_slot = slot
            self.info_clip = clip
            self.info_maxammo = maxammo

        def __getattr__(self, x):
예제 #6
0
   # Populate the new WeaponManager with Weapon instances
   weapons = ini['weapons']
   for w in weapons:
      current = weapons[w]
      maxammo = current.get('maxammo', '0')
      if maxammo.isdigit():
         maxammo = int(maxammo)
      else:
         maxammo = es.ServerVar('ammo_' + maxammo + '_max')
      manager._registerWeapon(w, current.get('ammoprop', None), current.get('tags', '').split(','),
       int(current.get('slot', 0)), int(current.get('clip', 0)), maxammo)

   # Return a WeaponManager instance for this game
   return manager

currentgame = getGameWeapons(es.getGameName()) or NoWeaponManager(es.getGameName())

###

def getWeapon(*a, **kw):
   return currentgame.getWeapon(*a, **kw)
getWeapon.__doc__ = WeaponManager.getWeapon.__doc__

def getWeaponList(*a, **kw):
   return currentgame.getWeaponList(*a, **kw)
getWeaponList.__doc__ = WeaponManager.getWeaponList.__doc__

def getWeaponNameList(*a, **kw):
   return currentgame.getWeaponNameList(*a, **kw)
getWeaponNameList.__doc__ = WeaponManager.getWeaponNameList.__doc__
예제 #7
0
        current = weapons[w]
        maxammo = current.get('maxammo', '0')
        if maxammo.isdigit():
            maxammo = int(maxammo)
        else:
            maxammo = es.ServerVar('ammo_' + maxammo + '_max')
        manager._registerWeapon(w, current.get('ammoprop', None),
                                current.get('tags', '').split(','),
                                int(current.get('slot', 0)),
                                int(current.get('clip', 0)), maxammo)

    # Return a WeaponManager instance for this game
    return manager


currentgame = getGameWeapons(es.getGameName()) or NoWeaponManager(
    es.getGameName())

###


def getWeapon(*a, **kw):
    return currentgame.getWeapon(*a, **kw)


getWeapon.__doc__ = WeaponManager.getWeapon.__doc__


def getWeaponList(*a, **kw):
    return currentgame.getWeaponList(*a, **kw)
예제 #8
0
# ./addons/eventscripts/_libs/python/weaponlib.py

import es
from collections import deque

import psyco
psyco.full()


gamename = es.getGameName()

class WeaponManager(object):
   class Weapon(str):
      """ Represents weapons, returning property information and an uniform name """
      def __init__(self, name):
         str.__init__(self, name)
         self.info_name = name

      def setAttributes(self, ammoprop='', tags=(), slot=0, clip=0, maxammo=0):
         self.info_ammoprop = ammoprop
         self.info_tags     = (tags,) if isinstance(tags, str) else tuple(tags)
         self.info_slot     = slot
         self.info_clip     = clip
         self.info_maxammo  = maxammo

      def __getattr__(self, x):
         try:
            return self.get(x)

         except ValueError:
            raise AttributeError, "Weapon instance has no attribute '%s'" % x