Exemple #1
0
def strip(users):
    '''Remove all weapons owned by a player...'''
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player dead?
        if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
            
            # Don't go further...
            continue
            
        # Loop through all weapon slots...
        for x in range(0, 65):
            
            # Get the weapon index...
            index = es.getindexfromhandle(es.getplayerprop(
                userid, 'CBaseCombatCharacter.m_hMyWeapons.%03d' % x))
                
            # Is the weapon not valid?
            if not index:
                
                # Don't go further...
                continue
                
            # Remove the weapon entity...
            spe.call('Remove', spe.getEntityOfIndex(index))
            
        # Remove the player's viewmodel...
        es.setplayerprop(
            userid, 'CBasePlayer.localdata.m_Local.m_bDrawViewmodel', 0)
def getViewCoords(userid, mask=0xFFFFFFFF, collisiongroup=0):
    player   = playerlib.getPlayer(userid)
    startvec = player.getEyeLocation()

    # Create start and end vector pointers
    pStart = createVector(*startvec)
    pEnd   = createVector(*list(Vector(startvec) + Vector(player.viewvector) \
        * MAX_COORD_RANGE))

    # Allocate space for the CGameTrace object
    ptr = spe.alloc(SIZE_TRACE_T)

    # Call UTIL_TraceLine()
    spe.call('TraceLine', pStart, pEnd, mask, spe.getPlayer(int(userid)),
        collisiongroup, ptr)

    # Wrap the end vector...
    x = spe.makeObject('Vector', ptr + 12)

    # ... and save the result
    result = x.x, x.y, x.z

    # Deallocate reserved space
    spe.dealloc(pStart)
    spe.dealloc(pEnd)
    spe.dealloc(ptr)

    # Finally, return the result
    return result
Exemple #3
0
    def __del__(self):
        '''
        Calls the destructor and frees the memory.
        '''

        spe.call('RecipientFilterDest', self)
        spe.dealloc(self)
def getViewCoords(userid, mask=0xFFFFFFFF, collisiongroup=0):
    player = playerlib.getPlayer(userid)
    startvec = player.getEyeLocation()

    # Create start and end vector pointers
    pStart = createVector(*startvec)
    pEnd   = createVector(*list(Vector(startvec) + Vector(player.viewvector) \
        * MAX_COORD_RANGE))

    # Allocate space for the CGameTrace object
    ptr = spe.alloc(SIZE_TRACE_T)

    # Call UTIL_TraceLine()
    spe.call('TraceLine', pStart, pEnd, mask, spe.getPlayer(int(userid)),
             collisiongroup, ptr)

    # Wrap the end vector...
    x = spe.makeObject('Vector', ptr + 12)

    # ... and save the result
    result = x.x, x.y, x.z

    # Deallocate reserved space
    spe.dealloc(pStart)
    spe.dealloc(pEnd)
    spe.dealloc(ptr)

    # Finally, return the result
    return result
Exemple #5
0
def give(users, entity):
    '''Give a entity to a player...'''
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Give the entity...
        spe.call('GiveNamedItem', spe.getPlayer(userid), entity, -0)
def removeEntityByInstance(entity_instance):
    # Make sure it's valid
    if not entity_instance:
        # Return false if the entity was None.
        return False

    # Remove it!
    spe.call("Remove", entity_instance)

    return True
Exemple #7
0
def removeEntityByInstance(entity_instance):
    # Make sure it's valid
    if not entity_instance:
        # Return false if the entity was None.
        return False

    # Remove it!
    spe.call("Remove", entity_instance)

    return True
Exemple #8
0
    def __new__(cls, users):
        '''
        Adds all given users to the new created pointer.
        '''

        pointer = spe.alloc(40)
        spe.call('RecipientFilterConst', pointer)
        for userid in getUsers(users):
            player = spe.getPlayer(userid)
            spe.call('AddRecipient', pointer, player)

        return super(cls, cls).__new__(cls, pointer)
def setStringKeyvalue(entity_index, keyvalue_name, new_value):
    # Get entity instance
    pEntity = spe.getEntityOfIndex(int(entity_index))

    # Make sure the entity is valid
    if not pEntity:
        # Return False if the entity was None.
        return False

    # Set the keyvalue
    spe.call("setkv_string", pEntity, keyvalue_name, new_value)

    return True
def removeEntityByIndex(entity_index):
    # Get entity instance
    pEntity = spe.getEntityOfIndex(int(entity_index))

    # Make sure it's valid
    if not pEntity:
        # Return false if the entity was None.
        return False

    # Remove it!
    spe.call("Remove", pEntity)

    return True
Exemple #11
0
def removeEntityByIndex(entity_index):
    # Get entity instance
    pEntity = spe.getEntityOfIndex(int(entity_index))

    # Make sure it's valid
    if not pEntity:
        # Return false if the entity was None.
        return False

    # Remove it!
    spe.call("Remove", pEntity)

    return True
def respawn(userid):
    # Get the player instance
    pPlayer = spe.getPlayer(int(userid))

    # Make sure the player instance is valid
    if not pPlayer:
        # Return False since the player instance was not valid
        return False

    # Respawn the player
    spe.call("Respawn", pPlayer)

    return True
def switchTeam(userid, team_index):
    # Get the player instance
    pPlayer = spe.getPlayer(int(userid))

    # Is the player instance valid?
    if not pPlayer:
        # Return False since the player instance was not valid
        return False

    # Switch their team
    spe.call("ChangeTeam", pPlayer, int(team_index))

    return True
Exemple #14
0
def setStringKeyvalue(entity_index, keyvalue_name, new_value):
    # Get entity instance
    pEntity = spe.getEntityOfIndex(int(entity_index))

    # Make sure the entity is valid
    if not pEntity:
        # Return False if the entity was None.
        return False

    # Set the keyvalue
    spe.call("setkv_string", pEntity, keyvalue_name, new_value)

    return True
Exemple #15
0
def _remove_entity(index):
    '''Remove the given entity index...'''
    
    # Get the entity pointer...
    pEntity = spe.getEntityOfIndex(index)
    
    # Is the entity not valid?
    if not pEntity:
        
        # Don't go further...
        return
        
    # Remove the entity...
    spe.call('Remove', pEntity)
Exemple #16
0
def spawn(users, force_respawn=False):
    '''Respawn a player...'''
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Get the player's dead state...
        isdead = es.getplayerprop(userid, 'CBasePlayer.pl.deadflag')
        
        # Does we need to respawn the player?
        if force_respawn or isdead:
            
            # Respawn the player...
            spe.call('Respawn', spe.getPlayer(userid))
Exemple #17
0
def changeTeam(users, teamid):
    '''Switch a player to the given team...'''
    
    # Format the given team...
    teamid = str(teamid).lower()
    
    # Is the team not valid?
    if not g_TeamIndexes.has_key(teamid):
        
        # Don't go further...
        return
        
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Switch the player...
        spe.call('ChangeTeam', spe.getPlayer(userid), g_TeamIndexes[teamid])
Exemple #18
0
def ownsWeapon(userid, weapon_name):
    # Get player instance
    pPlayer = spe.getPlayer(int(userid))

    if not pPlayer:
        return None

    # Call function and return weapon instance
    return spe.call("OwnsWeapon", pPlayer, weapon_name, 0)
def getWeaponFromSlot(userid, weapon_slot):
    # Get player instance
    pPlayer = spe.getPlayer(int(userid))

    if not pPlayer:
        return None

    # Call function and return player weapon instance
    return spe.call("GetWeapon", pPlayer, int(weapon_slot))
Exemple #20
0
def getWeaponFromSlot(userid, weapon_slot):
    # Get player instance
    pPlayer = spe.getPlayer(int(userid))

    if not pPlayer:
        return None

    # Call function and return player weapon instance
    return spe.call("GetWeapon", pPlayer, int(weapon_slot))
def ownsWeapon(userid, weapon_name):
    # Get player instance
    pPlayer = spe.getPlayer(int(userid))

    if not pPlayer:
        return None

    # Call function and return weapon instance
    return spe.call("OwnsWeapon", pPlayer, weapon_name, 0)
def createEntity(entity_name):
    """
    Left4Dead's CreateEntityByName function has an extra parameter.
    I set this to true.

    This function returns a pointer to the entity you just created.
    It returns None if the entity could not be created.
    """

    return spe.call("CreateEntity", entity_name, -1, 1)
def giveNamedItem(userid, item_name):
    # Get the player instance
    pPlayer = spe.getPlayer(int(userid))

    # Is the player instance valid?
    if not pPlayer:
        # Return None since the player instance was not valid
        return None

    # Give the player the item
    return spe.call('GiveNamedItem', pPlayer, str(item_name), 0)
def getActiveWeapon(userid):
    # Get the player instance
    pPlayer = spe.getPlayer(int(userid))

    # Is the player instance valid?
    if not pPlayer:
        # Return None since the player instance was not valid
        return None

    # Call and return player's active weapon
    return spe.call("GetActiveWeapon", pPlayer)
Exemple #25
0
def removeWeapon(users, weapon):
    '''Remove a player weapon...'''
    
    # Loop through all matching players...
    for userid in _get_matching_players(users):
        
        # Is the player dead?
        if es.getplayerprop(userid, 'CBasePlayer.pl.deadflag'):
            
            # Don't go further...
            continue
            
        # Is the given weapon an integer?
        if str(weapon).isdigit():
            
            # Get the weapon by its slot...
            pWeapon = spe.call(
                'GetWeapon', spe.getPlayer(userid), int(weapon))
                
        # Otherwise...
        else:
            
            # Is the weapon not starting by 'weapon_'?
            if not str(weapon).lower().startswith('weapon_'):
                
                # Add the 'weapon_' prefix...
                weapon = 'weapon_' + weapon
                
            # Get the weapon by its name...
            pWeapon = spe.call(
                'OwnsWeapon', spe.getPlayer(userid), str(weapon), 0)
                
        # Is the weapon not valid?
        if not pWeapon:
            
            # Don't go further...
            continue
            
        # Remove the weapon...
        spe.call('Remove', pWeapon)
def dropWeapon(userid, weapon_name, throwWeapon=True):
    # Get the player instance
    pPlayer = spe.getPlayer(int(userid))

    # Is the player instance valid?
    if not pPlayer:
        # Return False since the player instance was not valid
        return False

    # Get the weapon instance
    weapon_instance = spe.ownsWeapon(userid, weapon_name)

    # Is the weapon instance valid?
    if not weapon_instance:
        # Return False since the weapon instance was not valid
        return False

    # Throw the weapon?
    if throwWeapon:
        return spe.call('DropWeapon', pPlayer, weapon_instance, 0, 1)

    # Otherwise, don't.
    return spe.call('DropWeapon', pPlayer, weapon_instance, 0, 0)
Exemple #27
0
def getViewEntity(userid):
    '''Get the entity a player is looking at...'''
    
    # Is the player not valid?
    if not es.exists('userid', userid):
        
        # Don't go further...
        return None
        
    # Get the entity pointer...
    pEntity = spe.call('FindPickerEntity', spe.getPlayer(int(userid)))
    
    # Is the entity not valid?
    if not pEntity:
        
        # Don't go further...
        return None
        
    # Return the entity index...
    return spe.getEntityIndex(pEntity)
Exemple #28
0
def getEntityOfIndex(entity_index):
    # Call and return
    return spe.call("EntityByIndex", int(entity_index))
Exemple #29
0
def test():
    for userid in es.getUseridList():
        if es.isbot(userid):
            spe.call("NHide", spe.getPlayer(userid), -1, 9999, 1)
def getEntityOfIndex(entity_index):
    # Call and return
    return spe.call("EntityByIndex", int(entity_index))
def createEntity(entity_name):
    # Call the function
    # Last parameter must be -1.
    return spe.call("CreateEntity", entity_name, -1)
Exemple #32
0
def pre_setstate(args):
    spe.call("TryToHide", args[2], 1, 1, 1, 0, 1)
    return (spe.HookAction.Continue, 0)
Exemple #33
0
def createEntity(entity_name):
    # Call the function
    # Last parameter must be -1.
    return spe.call("CreateEntity", entity_name, -1)
Exemple #34
0
def test():
    for userid in es.getUseridList():
        if es.isbot(userid):
            spe.call("NHide", spe.getPlayer(userid), -1, 9999, 1)
Exemple #35
0
def pre_setstate(args):
    spe.call("TryToHide", args[2], 1, 1, 1, 0, 1)
    return (spe.HookAction.Continue, 0)