コード例 #1
0
ファイル: Denial.py プロジェクト: The-Sky/infinity-rpg
def clientFilter(userid, args):
    if args[0].lower() == 'drop':
        weapon = es.createplayerlist(userid)[userid]['weapon']
        if weapon not in ('weapon_knife', 'weapon_flashbang', 'weapon_smokegrenade', 'weapon_hegrenade'):
            if weapon in weaponlib.getWeaponList('#primary'):
                del weaponList[int(userid)]['primary']
            elif weapon in weaponlib.getWeaponList('#secondary'):
                del weaponList[int(userid)]['secondary']  
    return True
コード例 #2
0
ファイル: Denial.py プロジェクト: The-Sky/infinity-rpg
def item_pickup(ev):
    userid = int(ev['userid'])
    if userid in allowChange:
        item = 'weapon_%s' %(ev['item'])
        if item not in ('weapon_knife', 'weapon_c4'):
            if item in weaponlib.getWeaponList('#primary'):
                weaponList[userid]['primary'] = item
            elif item in weaponlib.getWeaponList('#secondary'):
                weaponList[userid]['secondary'] = item
            else:
                if not item == 'weapon_defuser':
                    weaponList[userid]['items'].append(item)
                else:
                    weaponList[userid]['items'].append('item_defuser')   
コード例 #3
0
ファイル: Impulse.py プロジェクト: dretax/MeowRPG
def player_hurt(ev):
    if (ev['weapon']
            not in ('usp', 'glock', 'p228', 'deagle', 'fiveseven', 'elite')
            or not skillhandler.IsLoaded('Frostpistol') or
        (ev['weapon'] in
         ('usp', 'glock', 'p228', 'deagle', 'fiveseven', 'elite')
         and playerlist[ev['attacker']].GetSkillLevel('Frostpistol')
         == 0)) and ev['weapon'] != 'knife' and int(ev['attacker']) != 0:
        # Get userid, level of this skill and playelib instance
        userid = int(ev['userid'])
        player = playerlist[userid]
        level = player.GetSkillLevel(skillname)
        # Set speed
        player.player.setSpeed(player.properties['speed'] +
                               rpgImpulseSpeed * level)
        player = player.player
        # Set ammo
        if rpgImpulseActiveOnly:
            activeWeapon = es.entitygetvalue(
                es.getindexfromhandle(
                    es.getplayerprop(userid,
                                     "CBasePlayer.baseclass.m_hActiveWeapon")),
                "classname")
            if activeWeapon in weaponlib.getWeaponList('#primary'):
                try:
                    player.setPrimaryClip(
                        int(player.getClip('1')) + level * rpgImpulseAmmo)
                except:
                    pass
            elif activeWeapon in weaponlib.getWeaponList('#secondary'):
                try:
                    player.setSecondaryClip(
                        int(player.getClip('2')) + level * rpgImpulseAmmo)
                except:
                    pass
        else:
            try:
                player.setPrimaryClip(
                    int(player.getClip('1')) + level * rpgImpulseAmmo)
            except:
                pass
            try:
                player.setSecondaryClip(
                    int(player.getClip('2')) + level * rpgImpulseAmmo)
            except:
                pass
        # Delay
        delayname = 'rpg_%s_%s' % (skillname, userid)
        gamethread.cancelDelayed(delayname)
        gamethread.delayedname(1, delayname, rpg_repulse, (userid))
コード例 #4
0
ファイル: foreach.py プロジェクト: AlexxDone/WCS_GO
def register(args):
	if len(args) >= 1:
		target = str(args[0]).lower()

		if target == 'player':
			if len(args) >= 4:
				var = str(args[1])
				id  = str(args[2])
				cmd = ' '.join(args[3:])

				if id.startswith('#'):
					for user in getUseridList(id):
						server.insertcmd('es_xset '+var+' '+str(user)+';'+cmd)
				else:
					server.insertcmd('es_xset '+var+' '+id+';'+cmd)

		elif target == 'weapon':
			if len(args) >= 4:
				var = str(args[1])
				id  = str(args[2])
				cmd = ' '.join(args[3:])

				for weapon in getWeaponList(id):
					server.insertcmd('es_xset '+var+' '+str(weapon)+';'+cmd)

		elif target == 'token':
			if len(args) >= 5:
				var    = str(args[1])
				string = str(args[2])
				sep    = str(args[3])
				cmd    = ' '.join(args[3:])

				for token in string.split(sep):
					if len(token):
						server.insertcmd('es_xset '+var+' '+str(token)+';'+cmd)
コード例 #5
0
def testcase():
    playercount = len(playerlib.getUseridList('#all'))
    weaponcount = len(weaponlib.getWeaponList('#all'))
    entitycount = len(es.createentitylist('env_fire'))
    for line in (
            'profile begin foreach_test', 'profile begin foreach_player',
            'testlib begin foreach_player "foreach player #all"',
            'es_xset _foreach_count 0',
            'foreach player _foreach_testvar #all "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto %d' % playercount,
            'testlib end', 'profile end foreach_player',
            'profile begin foreach_weapon',
            'testlib begin foreach_weapon "foreach weapon #all"',
            'es_xset _foreach_count 0',
            'foreach weapon _foreach_testvar #all "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto %d' % weaponcount,
            'testlib end', 'profile end foreach_weapon',
            'profile begin foreach_entity',
            'testlib begin foreach_entity "foreach entity env_fire"',
            'es_xset _foreach_count 0',
            'foreach entity _foreach_testvar _foreach_testvar env_fire "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto %d' % entitycount,
            'testlib end', 'profile end foreach_entity',
            'profile begin foreach_token',
            'testlib begin foreach_token "foreach token"',
            'es_xset _foreach_count 0',
            'foreach token _foreach_testvar "a-ab-abc-abcd-abcde" - "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto 5', 'testlib end',
            'profile end foreach_token', 'profile begin foreach_part',
            'testlib begin foreach_part "foreach part"',
            'es_xset _foreach_count 0',
            'foreach part _foreach_testvar "a1b2c3d4e5" 2 "es_xmath _foreach_count + 1"',
            'testlib fail_unless _foreach_count equalto 5', 'testlib end',
            'profile end foreach_part', 'profile end foreach_test'):
        es.server.cmd(line)
コード例 #6
0
ファイル: gameevents.py プロジェクト: cagemonkey/GunGame
def round_start(event_var):
    '''Called at the start of every round'''

    # Remove weapons from the map
    do_not_strip = [(x.strip() if x.strip().startswith('weapon_') else
                     'weapon_%s' % x.strip())
                    for x in str(gg_map_strip_exceptions).split(',')
                    if x.strip() != '']

    for weapon in getWeaponList('#all'):
        # Make sure that the admin doesn't want the weapon left on the map
        if weapon in do_not_strip:
            continue

        # Remove all weapons of this type from the map
        for index in weapon.indexlist:
            # If the weapon has an owner, stop here
            if es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity') != -1:
                continue

            removeEntityByIndex(index)

    # Equip players with a knife and
    # possibly item_kevlar or item_assaultsuit
    equip_player()
コード例 #7
0
ファイル: Regen Ammo.py プロジェクト: Grimston/sourcerpg-es
 def addAmmo(self, amount):
     """
     This function gets the current weapons of the user and adds ammo
     to their weapons.
     
     @PARAM amount - amount of ammo to add
     """
     weaponList  = weaponlib.getWeaponList('#primary')
     weaponList += weaponlib.getWeaponList("#secondary")
     for weapon in weaponList:
         for index in weapon.indexlist:
             if es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity') == self.handle:
                 maxAmmo = weapon.maxammo
                 prop    = weapon.prop
                 currentAmmo = es.getplayerprop(self.userid, prop)
                 
                 currentAmmo += amount
                 if currentAmmo > maxAmmo:
                     currentAmmo = maxAmmo
                 es.setplayerprop(self.userid, prop, currentAmmo)
コード例 #8
0
ファイル: ultilib.py プロジェクト: smurfix/playground
 def replacePrimaryWeapon(self, prim_wep):
     """Replace the primary weapon
     prim_wep - the name of a primary weapon"""
     validwep = tuple(weaponlib.getWeaponList("#primary"))
     if prim_wep not in validwep:
         raise TypeError("You must have a valid weapon to switch a secondary weapon")
     else:
         currentprim = self.getPrimary()
         if currentprim:
             if currentprim == prim_wep:
                 return
             self.removePrimary()
         es.give(self.userid, prim_wep)
コード例 #9
0
def testcase():
    playercount = len(playerlib.getUseridList('#all'))
    weaponcount = len(weaponlib.getWeaponList('#all'))
    entitycount = len(es.createentitylist('env_fire'))
    for line in (
        'profile begin foreach_test',
        'profile begin foreach_player',
        'testlib begin foreach_player "foreach player #all"',
        'es_xset _foreach_count 0',
        'foreach player _foreach_testvar #all "es_xmath _foreach_count + 1"',
        'testlib fail_unless _foreach_count equalto %d' % playercount,
        'testlib end',
        'profile end foreach_player',
        'profile begin foreach_weapon', 
        'testlib begin foreach_weapon "foreach weapon #all"',
        'es_xset _foreach_count 0',
        'foreach weapon _foreach_testvar #all "es_xmath _foreach_count + 1"',
        'testlib fail_unless _foreach_count equalto %d' % weaponcount,
        'testlib end',
        'profile end foreach_weapon',
        'profile begin foreach_entity',
        'testlib begin foreach_entity "foreach entity env_fire"',
        'es_xset _foreach_count 0',
        'foreach entity _foreach_testvar _foreach_testvar env_fire "es_xmath _foreach_count + 1"',
        'testlib fail_unless _foreach_count equalto %d' % entitycount,
        'testlib end',
        'profile end foreach_entity',
        'profile begin foreach_token',
        'testlib begin foreach_token "foreach token"',
        'es_xset _foreach_count 0',
        'foreach token _foreach_testvar "a-ab-abc-abcd-abcde" - "es_xmath _foreach_count + 1"',
        'testlib fail_unless _foreach_count equalto 5',
        'testlib end',
        'profile end foreach_token',
        'profile begin foreach_part',
        'testlib begin foreach_part "foreach part"',
        'es_xset _foreach_count 0',
        'foreach part _foreach_testvar "a1b2c3d4e5" 2 "es_xmath _foreach_count + 1"',
        'testlib fail_unless _foreach_count equalto 5',
        'testlib end',
        'profile end foreach_part',
        'profile end foreach_test'):
        es.server.cmd(line)
コード例 #10
0
ファイル: gg_dead_strip.py プロジェクト: cagemonkey/GunGame
def removeIdleLoop():
    list_noStrip = [(x.strip() if x.strip().startswith('weapon_') else
        'weapon_%s' % x.strip()) for x in
        str(gg_map_strip_exceptions).split(',') if x.strip() != '']

    for weapon in getWeaponList('#all'):
        # Make sure that the admin doesn't want the weapon left on the map
        if weapon in list_noStrip:
            continue

        # Remove all weapons of this type from the map
        for index in weapon.indexlist:
            # If the weapon has an owner, stop here
            if es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity') != -1:
                continue

            spe.removeEntityByIndex(index)

    gamethread.delayedname(5, "gg_removeIdleLoop", removeIdleLoop)
コード例 #11
0
def removeIdleLoop():
    list_noStrip = [
        (x.strip() if x.strip().startswith('weapon_') else 'weapon_%s' %
         x.strip()) for x in str(gg_map_strip_exceptions).split(',')
        if x.strip() != ''
    ]

    for weapon in getWeaponList('#all'):
        # Make sure that the admin doesn't want the weapon left on the map
        if weapon in list_noStrip:
            continue

        # Remove all weapons of this type from the map
        for index in weapon.indexlist:
            # If the weapon has an owner, stop here
            if es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity') != -1:
                continue

            spe.removeEntityByIndex(index)

    gamethread.delayedname(5, "gg_removeIdleLoop", removeIdleLoop)
コード例 #12
0
ファイル: gameevents.py プロジェクト: robtomlinson/GunGame
def round_start(event_var):
    '''Called at the start of every round'''

    # Remove weapons from the map
    do_not_strip = [(x.strip() if x.strip().startswith('weapon_') else
        'weapon_%s' % x.strip()) for x in str(
        gg_map_strip_exceptions).split(',') if x.strip() != '']

    for weapon in getWeaponList('#all'):
        # Make sure that the admin doesn't want the weapon left on the map
        if weapon in do_not_strip:
            continue

        # Remove all weapons of this type from the map
        for index in weapon.indexlist:
            # If the weapon has an owner, stop here
            if es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity') != -1:
                continue

            removeEntityByIndex(index)

    # Equip players with a knife and
    # possibly item_kevlar or item_assaultsuit
    equip_player()
コード例 #13
0
info.version = "5.1.%s" % "$Rev: 622 $".split('$Rev: ')[1].split()[0]
info.translations = ['gg_warmup_round']

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
mp_freezetime = es.ServerVar('mp_freezetime')
warmup_timer = es.ServerVar('gg_warmup_timer')
warmup_weapon = es.ServerVar('gg_warmup_weapon')
warmup_start_file = es.ServerVar('gg_warmup_start_file')
warmup_end_file = es.ServerVar('gg_warmup_end_file')
warmup_round_min_players = es.ServerVar('gg_warmup_round_min_players')
warmup_round_max_extensions = es.ServerVar('gg_warmup_round_max_extensions')
warmup_round_players_reached = es.ServerVar('gg_warmup_round_players_reached')

possible_weapons = [weapon.basename for weapon in getWeaponList('#primary')]
possible_weapons.extend(weapon.basename
                        for weapon in getWeaponList('#secondary'))
possible_weapons.append('hegrenade')


# =============================================================================
# >> CLASSES
# =============================================================================
class WarmupRoundRepeat(Repeat):
    '''Class that extends the Repeat functionality for use by Warmup Round'''
    def extend_warmup_time(self):
        '''Extends the Warmup timer'''

        # Extend Warmup Time
        self.extend(int(warmup_timer))
コード例 #14
0
ファイル: __init__.py プロジェクト: robtomlinson/GunGame

# =============================================================================
# >> 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
# =============================================================================
class WeaponOrderError(Exception):
    pass


class _BaseWeaponOrder(object):
    def __init__(self, path_instance):
        self._name = path_instance.namebase
        self._filepath = path_instance
        self._title = self.name.replace('_', ' ').title()
コード例 #15
0
info.translations = ["gg_warmup_round"]


# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
mp_freezetime = es.ServerVar("mp_freezetime")
warmup_timer = es.ServerVar("gg_warmup_timer")
warmup_weapon = es.ServerVar("gg_warmup_weapon")
warmup_start_file = es.ServerVar("gg_warmup_start_file")
warmup_end_file = es.ServerVar("gg_warmup_end_file")
warmup_round_min_players = es.ServerVar("gg_warmup_round_min_players")
warmup_round_max_extensions = es.ServerVar("gg_warmup_round_max_extensions")
warmup_round_players_reached = es.ServerVar("gg_warmup_round_players_reached")

possible_weapons = [weapon.basename for weapon in getWeaponList("#primary")]
possible_weapons.extend(weapon.basename for weapon in getWeaponList("#secondary"))
possible_weapons.append("hegrenade")


# =============================================================================
# >> CLASSES
# =============================================================================
class WarmupRoundRepeat(Repeat):
    """Class that extends the Repeat functionality for use by Warmup Round"""

    def extend_warmup_time(self):
        """Extends the Warmup timer"""

        # Extend Warmup Time
        self.extend(int(warmup_timer))