Пример #1
0
def clientFilter(userid, args):
    """
    Executed when a client command is issued from a player. Test to see if drop
    was the command; if so, then remove the weapon.

    @PARAM userid - the id of the user who issued the client command
    @PARAM args - a list of arguments, with index 0 being the command.
    """
    if args and args[0].lower() == "drop":
        """ Player is about to issue the drop command """
        player = sourcerpg.players[userid]
        level  = player[skillName]
        if level:
            """ The player has recover weapons, get their active weapn and remove it """
            weapon = weaponlib.getWeapon(playerlib.getPlayer(userid).get("weapon"))
            if weapon is None:
                # The user has no weapons, allow them to run the drop command
                return True

            weapon = weapon.name # return formated weapon
            
            if level >= 3 and weapon in weaponlib.getWeaponNameList("#primary"):
                player['primary'] = None

            elif level >= 2 and weapon in weaponlib.getWeaponNameList("#secondary"):
                player['secondary'] = None

    return True
Пример #2
0
def item_pickup(event_var):
    """
    Exeecuted when a player picks up a weapon. Store their current weapon
    so it remembers the value

    @PARAM event_var - an automatically passed event instance
    """
    weapon = weaponlib.getWeapon(event_var['item'])
    if weapon is None:
        """ The item picked up is not a valid weapon, return early """
        return
    weapon = weapon.name # format the weapon name
    userid = event_var['userid']
    player = sourcerpg.players[userid]
    if player is not None:
        level  = player[skillName]
        if level:
            """ Player is at least level 1 in this skill """
            if weapon in weaponlib.getWeaponNameList('#primary') and level >= 3:
                player['primary'] = weapon

            elif weapon in weaponlib.getWeaponNameList('#secondary') and level >= 2:
                if weapon != {2 : "weapon_glock", 3 : "weapon_usp"}[es.getplayerteam(userid)]:
                    player['secondary'] = weapon

            elif weapon in weaponlib.getWeaponNameList('#grenade'):
                player[weapon] += 1
Пример #3
0
def player_hurt(event_var):
    """
    When a player is damaged, check for team attacks, then if the weapon is
    a secondary weapon then freeze the player
    
    @PARAM event_var - an automatically passed event instance
    """
    userid   = event_var['userid']
    attacker = event_var['attacker']
    if int(attacker):
        """ The attacker did not hurt themselves """
        player = sourcerpg.players[attacker]
        level  = player[skillName]
        if level:
            """ The player has at least level 1 in this skill """
            if event_var['es_userteam'] <> event_var['es_attackerteam']:
                """ It was not a team kill """
                if event_var['weapon'] in map(lambda x: x.split('_')[-1], weaponlib.getWeaponNameList('#secondary')):
                    victim = sourcerpg.players[userid]
                    speed  = victim['maxSpeed']
                    if not victim['slowed']:
                        """ If they're frozen, there's no point (i,e Ice Stab) """
                        playerlibInstance = playerlib.getPlayer(userid)
                        if not playerlibInstance.getFreeze():
                            """ Ensure that they're only slowed once """
                            victim['slowed'] = True
                            speed /= 2.0
                            victim['maxSpeed'] = speed
                            playerlibInstance.speed = speed
                            playerlibInstance.setColor(0, 0, 255)
                            gamethread.delayedname(float(freezeTime) * level, 'sourcerpg_slow_user%s' % userid, speedUp, (userid, speed * 2.0))
                    else:
                        gamethread.cancelDelayed("sourcerpg_slow_user%s" % userid)
                        gamethread.delayedname(float(freezeTime) * level, 'sourcerpg_slow_user%s' % userid, speedUp, (userid, speed * 2.0))
Пример #4
0
def player_hurt(event_var):
    """
    Executed when a player is damaged. Retrieve the victims level and speed
    them up if they aren't already in the adrenaline mode
    
    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    player = sourcerpg.players[userid]
    level = player[skillName]
    if level:
        """ Player is at least level 1 in this skill """
        if not player['adrenalined'] and not player['slowed']:
            """ Player is not already in the adrenaline mode """
            attacker = event_var['attacker']
            if attacker and attacker.isdigit() and int(attacker) > 1:
                """ If the attacker is a valid attacker """
                if event_var['es_attackerteam'] != event_var['es_userteam']:
                    """ If the attacker is not on the user's team """
                    if "Frost Pistol" in sourcerpg.skills:
                        """ If frost pistol is loaded check if the attack was a frost pistol attack """
                        if sourcerpg.players[attacker]['Frost Pistol']:
                            """ If the attacker has a frost pistol level """
                            weapon = event_var['weapon']
                            weapon = weaponlib.getWeapon(weapon)
                            if weapon is None:
                                return
                            weapon = weapon.name  # format the weapon name
                            if weapon in weaponlib.getWeaponNameList(
                                    "#secondary"):
                                """ The attack was a frost pistol attack, return early """
                                return

                    player['adrenalined'] = True
                    amount = level / 10.
                    speed = player['maxSpeed'] + amount
                    """ Set the speed and the delay """
                    playerlibInstance = playerlib.getPlayer(userid)
                    playerlibInstance.speed = speed

                    if int(refreshAmmo):
                        currentWeapon = weaponlib.getWeapon(
                            playerlibInstance.weapon)
                        if currentWeapon is not None:
                            if random.randint(
                                    1, 100) <= float(clipRefreshPct) * level:
                                playerlibInstance.clip[
                                    currentWeapon.name] = currentWeapon.clip

                    gamethread.delayedname(
                        float(length), 'sourcerpg_adrenaline_user%s' % userid,
                        reset, (userid, speed - amount))
Пример #5
0
def foreach_weapon(variable, identifier, command):
    if '#' in identifier:
        identifier = identifier.replace('#hand', '#melee').replace('#nade', '#grenade')
        identifier = identifier.replace('#', ',#')[1:]
        weapons = []
        for weapon in identifier.split(","):
            weapons.extend(weaponlib.getWeaponNameList(weapon))
        while weapons:
            weapon = weapons[0]
            variable.set(str(weapon))
            es.server.cmd(command)
            while weapon in weapons: weapons.remove(weapon)
    else:
        es.dbgmsg(0, 'foreach weapon: The identifier "%s" does not exists' % identifier)
Пример #6
0
def player_hurt(event_var):
    """
    Executed when a player is damaged. Retrieve the victims level and speed
    them up if they aren't already in the adrenaline mode
    
    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    player = sourcerpg.players[userid]
    level  = player[skillName]
    if level:
        """ Player is at least level 1 in this skill """
        if not player['adrenalined'] and not player['slowed']:
            """ Player is not already in the adrenaline mode """
            attacker = event_var['attacker']
            if attacker and attacker.isdigit() and int(attacker) > 1:
                """ If the attacker is a valid attacker """
                if event_var['es_attackerteam'] != event_var['es_userteam']:
                    """ If the attacker is not on the user's team """
                    if "Frost Pistol" in sourcerpg.skills:
                        """ If frost pistol is loaded check if the attack was a frost pistol attack """
                        if sourcerpg.players[attacker]['Frost Pistol']:
                            """ If the attacker has a frost pistol level """
                            weapon = event_var['weapon']
                            weapon = weaponlib.getWeapon(weapon)
                            if weapon is None:
                                return
                            weapon = weapon.name # format the weapon name
                            if weapon in weaponlib.getWeaponNameList("#secondary"):
                                """ The attack was a frost pistol attack, return early """
                                return
                            
                    player['adrenalined'] = True
                    amount = level / 10.
                    speed  = player['maxSpeed'] + amount

                    """ Set the speed and the delay """
                    playerlibInstance = playerlib.getPlayer(userid)
                    playerlibInstance.speed = speed
                    
                    if int(refreshAmmo):
                        currentWeapon = weaponlib.getWeapon(playerlibInstance.weapon)
                        if currentWeapon is not None:
                            if random.randint(1, 100) <= float(clipRefreshPct) * level:
                                playerlibInstance.clip[currentWeapon.name] = currentWeapon.clip
                    
                    gamethread.delayedname( float(length), 'sourcerpg_adrenaline_user%s' % userid, reset, (userid, speed - amount))
Пример #7
0
def setDefaultAttributes(userid):
    """
    A function to assign the default attributes and values to the players
    object within SourceRPG. We need to delay by 0 seconds to ensure that
    1 tick is passed so we can be sure that the Player's object has been
    created.

    @PARAM userid - the id of the user we wish to assign the values to
    """
    player = sourcerpg.players[userid]
    if player is not None:
        player['recover']   = False
        player['primary']   = None
        player['secondary'] = None

        for weaponName in weaponlib.getWeaponNameList("#grenade"):
            player[weaponName] = 0
Пример #8
0
def foreach_weapon(variable, identifier, command):
    if '#' in identifier:
        identifier = identifier.replace('#hand',
                                        '#melee').replace('#nade', '#grenade')
        identifier = identifier.replace('#', ',#')[1:]
        weapons = []
        for weapon in identifier.split(","):
            weapons.extend(weaponlib.getWeaponNameList(weapon))
        while weapons:
            weapon = weapons[0]
            variable.set(str(weapon))
            es.server.cmd(command)
            while weapon in weapons:
                weapons.remove(weapon)
    else:
        es.dbgmsg(
            0,
            'foreach weapon: The identifier "%s" does not exists' % identifier)
Пример #9
0
def player_hurt(event_var):
    """
    When a player is damaged, check for team attacks, then if the weapon is
    a secondary weapon then freeze the player
    
    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    attacker = event_var['attacker']
    if int(attacker):
        """ The attacker did not hurt themselves """
        player = sourcerpg.players[attacker]
        level = player[skillName]
        if level:
            """ The player has at least level 1 in this skill """
            if event_var['es_userteam'] <> event_var['es_attackerteam']:
                """ It was not a team kill """
                if event_var['weapon'] in map(
                        lambda x: x.split('_')[-1],
                        weaponlib.getWeaponNameList('#secondary')):
                    victim = sourcerpg.players[userid]
                    speed = victim['maxSpeed']
                    if not victim['slowed']:
                        """ If they're frozen, there's no point (i,e Ice Stab) """
                        playerlibInstance = playerlib.getPlayer(userid)
                        if not playerlibInstance.getFreeze():
                            """ Ensure that they're only slowed once """
                            victim['slowed'] = True
                            speed /= 2.0
                            victim['maxSpeed'] = speed
                            playerlibInstance.speed = speed
                            playerlibInstance.setColor(0, 0, 255)
                            gamethread.delayedname(
                                float(freezeTime) * level,
                                'sourcerpg_slow_user%s' % userid, speedUp,
                                (userid, speed * 2.0))
                    else:
                        gamethread.cancelDelayed("sourcerpg_slow_user%s" %
                                                 userid)
                        gamethread.delayedname(
                            float(freezeTime) * level,
                            'sourcerpg_slow_user%s' % userid, speedUp,
                            (userid, speed * 2.0))
Пример #10
0
def giveObject(adminid, userid):
    command = admins[adminid]['command']
    if command.startswith(('health_', 'cash_')):
        prop   = 'CBasePlayer.m_iHealth' if command.startswith('health_') else 'CCSPlayer.m_iAccount'
        amount = int(command.replace('health_', '').replace('cash_', ''))
        currentAmount  = es.getplayerprop(userid, prop)
        es.setplayerprop(userid, prop, currentAmount + amount)
        # issue #70 :: value formatting error
        strInt = str(amount)
        thousands = []
        while strInt:
            thousands.append(strInt[-3:])
            strInt = strInt[:-3]
        formattedAmount = ",".join(reversed(thousands))
        tokens = {}
        tokens['admin'] = es.getplayername(adminid)
        tokens['user']  = es.getplayername(userid)
        tokens['item']  =  '#green%s #lightgreen%s' % (formattedAmount, 'cash' if command.startswith('cash_') else 'health')
        for tellplayer in playerlib.getPlayerList('#human'):
            es.tell(int(tellplayer), '#multi', xalanguage('admin give', tokens, tellplayer.get("lang")))
        xaadmingive.logging.log("has given player %s %s" % (tokens['user'], tokens['item']), adminid, True) 
    else:
        weaponName = _remove_prefix(command)
        fullName   = _prepend_prefix(command)
        if int(admingive_stripfirst) == 1:
            if fullName in weaponlib.getWeaponNameList('#secondary'):
                weapon = playerlib.getPlayer(userid).get('secondary')
            else:
                weapon = playerlib.getPlayer(userid).get('primary')
            if weapon:
                _remove_weapon(userid, weapon)
        es.delayed(0.1, 'es_xgive %s %s' % (userid, fullName))
        if str(admingive_anonymous) == '0':
            tokens = {}
            tokens['admin'] = es.getplayername(adminid)
            tokens['user']  = es.getplayername(userid)
            for tellplayer in playerlib.getPlayerList('#human'):
                tokens['item'] = '#greena #lightgreen%s' % weaponName
                es.tell(int(tellplayer), '#multi', xalanguage('admin give', tokens, tellplayer.get("lang")))
        xaadmingive.logging.log("has given player %s %s" % (tokens['user'], tokens['item']), adminid, True)            
Пример #11
0
def player_spawn(event_var):
    """
    Executed automatically when a player spawns. Test to see if their recover
    key is active, if so, activate their weapons and give them back their
    previous weapons.

    @PARAM event_var - an automatically passed event instance
    """
    userid = event_var['userid']
    if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
        """ The player is dead so we ignore this event, return early """
        return
    player = sourcerpg.players[userid]
    if player is not None:
        if player['recover']:
            level = player[skillName]
            if level:
                currentDelay = 0.1
                """ Player is at least level one in this skill """
                for weaponName in weaponlib.getWeaponNameList("#grenade"):
                    while player[weaponName] > 0:
                        gamethread.delayed(currentDelay, giveWeapon, (userid, weaponName))
                        player[weaponName] -= 1

                if level >= 2:
                    """ Player has at least level 2, give them back their secondary """
                    if player["secondary"]:
                        handle = es.getplayerhandle(userid)
                        for index in weaponlib.getIndexList({2 : "weapon_glock", 3 : "weapon_usp"}[es.getplayerteam(userid)]):
                            if es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity') == handle:
                                safeRemove(index)
                                break
                        gamethread.delayed(currentDelay, giveWeapon, (userid, player["secondary"]))

                if level >= 3:
                    """ Player has at least level 3, give them back their primary """
                    if player["primary"]:
                        gamethread.delayed(currentDelay, giveWeapon, (userid, player["primary"]))

                player['recover'] = False
Пример #12
0
def player_hurt(event_var):
    """
    When a player is damaged, check for team attacks, then if the wepapon is
    a hegrenade, then set the player on fire, and delay and extinguish
    
    @PARAM event_var - an automatically passed event instance
    """
    userid   = event_var['userid']
    attacker = event_var['attacker']
    if attacker and int(attacker) and attacker not in frozen:
        """ The attacker did not hurt themselves """
        player = sourcerpg.players[attacker]
        level  = player[skillName]
        if level:
            """ The player has at least level 1 in this skill """
            if event_var['es_userteam'] != event_var['es_attackerteam']:
                """ It was not a team kill """
                damage = 0
                if event_var['damage'].isdigit():
                    damage = int(event_var['damage'])
                elif event_var['dmg_health'].isdigit():
                    damage = int(event_var['dmg_health'])
                if event_var['weapon'] in map(lambda x: x.split('_')[-1], weaponlib.getWeaponNameList("#melee")):
                    if damage > 30:
                        """ The attack was a hard hit from one of the weapons """
                        if userid not in frozen:
                            frozen.append(userid)
                        gamethread.cancelDelayed('sourcerpg_freeze_user%s' % userid)
                        es.emitsound('player', userid, 'physics/glass/glass_impact_bullet%s.wav' % random.randint(1,4), '1.0', '0.5')
                        player = playerlib.getPlayer(userid)
                        player.freeze(True)
                        player.setColor(0, 0, 255)
                        gamethread.delayedname(float(iceTime) * level, 'sourcerpg_freeze_user%s' % userid, unFreeze, userid)
                elif bool(int(damageReduction)) and userid in frozen:
                    """ Damage reduction """
                    if not es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
                        player = playerlib.getPlayer(userid)
                        player.health += int(damage / 100. * damageReduction)
Пример #13
0
# >> ADDON REGISTRATION/INFORMATION
# =============================================================================
info = AddonInfo()
info.name = 'gg_dead_strip'
info.title = 'GG Dead Strip'
info.author = 'GG Dev Team'
info.version = "5.1.%s" % "$Rev: 592 $".split('$Rev: ')[1].split()[0]

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Get the es.ServerVar() instance of "gg_nade_bonus"
gg_nade_bonus = es.ServerVar('gg_nade_bonus')

# Retrieve a list of all available weapon names
list_weaponNameList = getWeaponNameList()

gg_map_strip_exceptions = es.ServerVar('gg_map_strip_exceptions')


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    # Register the drop command to prevent it from being used.
    es.addons.registerClientCommandFilter(drop_filter)

    #Start the idle weapon removal loop
    gamethread.delayedname(5, "gg_removeIdleLoop", removeIdleLoop)

    # Make sure that all owned weapons can NOT be picked up
Пример #14
0
# >> ADDON REGISTRATION/INFORMATION
# =============================================================================
info = AddonInfo()
info.name = 'gg_dead_strip'
info.title = 'GG Dead Strip'
info.author = 'GG Dev Team'
info.version = "5.1.%s" % "$Rev: 592 $".split('$Rev: ')[1].split()[0]

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Get the es.ServerVar() instance of "gg_nade_bonus"
gg_nade_bonus = es.ServerVar('gg_nade_bonus')

# Retrieve a list of all available weapon names
list_weaponNameList = getWeaponNameList()

gg_map_strip_exceptions = es.ServerVar('gg_map_strip_exceptions')


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    # Register the drop command to prevent it from being used.
    es.addons.registerClientCommandFilter(drop_filter)

    #Start the idle weapon removal loop
    gamethread.delayedname(5, "gg_removeIdleLoop", removeIdleLoop)

    # Make sure that all owned weapons can NOT be picked up
Пример #15
0
info.name = 'gg_nade_bonus'
info.title = 'GG Grenade Bonus'
info.author = 'GG Dev Team'
info.version = "5.1.%s" % "$Rev: 571 $".split('$Rev: ')[1].split()[0]
info.translations = ['gg_nade_bonus']

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Server Vars
gg_nade_bonus = es.ServerVar('gg_nade_bonus')
gg_nade_bonus_mode = es.ServerVar('gg_nade_bonus_mode')
gg_nade_bonus_reset = es.ServerVar('gg_nade_bonus_reset')

# Weapon list
list_Weapons = getWeaponNameList('#all')


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    # Adding attributes
    create_attributes('#all')


# =============================================================================
# >> GAME EVENTS
# =============================================================================
def player_spawn(event_var):
    userid = int(event_var['userid'])
Пример #16
0
info.name = 'gg_nade_bonus'
info.title = 'GG Grenade Bonus'
info.author = 'GG Dev Team'
info.version = "5.1.%s" % "$Rev: 571 $".split('$Rev: ')[1].split()[0]
info.translations = ['gg_nade_bonus']

# =============================================================================
# >> GLOBAL VARIABLES
# =============================================================================
# Server Vars
gg_nade_bonus = es.ServerVar('gg_nade_bonus')
gg_nade_bonus_mode = es.ServerVar('gg_nade_bonus_mode')
gg_nade_bonus_reset = es.ServerVar('gg_nade_bonus_reset')

# Weapon list
list_Weapons = getWeaponNameList('#all')


# =============================================================================
# >> LOAD & UNLOAD
# =============================================================================
def load():
    # Adding attributes
    create_attributes('#all')


# =============================================================================
# >> GAME EVENTS
# =============================================================================
def player_spawn(event_var):
    userid = int(event_var['userid'])
Пример #17
0
info.name       = 'Admin Give'
info.version    = '1.1'
info.author     = 'freddukes'
info.basename   = 'xaadmingive'

# Register with XA
xaadmingive  			 = xa.register('xaadmingive')
xalanguage 			     = xaadmingive.language.getLanguage()
admingive_anonymous      = xaadmingive.setting.createVariable('admingive_anonymous' , 0, 'Whether or not giving a player a weapon is anonymous... 1 = Anonymous, 0 = Global')
admingive_stripfirst     = xaadmingive.setting.createVariable("admingive_stripfirst", 1, 'Whether or not the target is striped of their weapon before being gave another.\n // Will only strip the same slot as their being given.')

# ==============================================================================
#   GLOBALS
# ==============================================================================
weapons = {}
weapons['pistols']  = set(weaponlib.getWeaponNameList('#pistol'))
weapons['shotguns'] = set(weaponlib.getWeaponNameList('#shotgun'))
weapons['smgs']     = set(weaponlib.getWeaponNameList('#smg'))
weapons['snipers']  = set(weaponlib.getWeaponNameList('#sniper'))
weapons['rifles']   = set(weaponlib.getWeaponNameList('#rifle'))
weapons['rifles']   = weapons['rifles'].difference(weapons['snipers'])
weapons['grenades'] = set(weaponlib.getWeaponNameList('#grenade'))
weapons['all']      = set(weaponlib.getWeaponNameList("#all"))
weapons['others']   = weapons['all'].difference(weapons['pistols']).difference(weapons['shotguns']).difference(weapons['smgs']).difference(weapons['rifles']).difference(weapons['snipers']).difference(weapons['grenades'])
weaponsOrder = ('pistols', 'shotguns', 'smgs', 'snipers', 'rifles', 'grenades', 'all', 'others')
admins   = {}
gamename = str(es.ServerVar('eventscripts_gamedir')).replace('\\', '/').split('/')[~0]

# ==============================================================================
#   GAME EVENTS
# ==============================================================================