def get(self, info): """ Returns weapon properties """ if info == 'name': return self.info_name elif info == 'basename': return self.info_basename elif info == 'prop': return self.info_ammoprop elif info == 'tags': return self.info_tags elif info == 'slot': return self.info_slot elif info == 'clip': return self.info_clip elif info == 'maxammo': return int(self.info_maxammo) elif info == 'indexlist': return list(es.getEntityIndexes(self)) elif info == 'indexiter': return iter(es.getEntityIndexes(self)) raise ValueError(f"No weapon info '{info}'")
def get(self, info): """ Returns weapon properties """ if info == 'name': return self.info_name elif info == 'basename': return self.info_basename elif info == 'prop': return self.info_ammoprop elif info == 'tags': return self.info_tags elif info == 'slot': return self.info_slot elif info == 'clip': return self.info_clip elif info == 'maxammo': return int(self.info_maxammo) elif info == 'indexlist': return list(es.getEntityIndexes(self)) elif info == 'indexiter': return iter(es.getEntityIndexes(self)) raise ValueError(f"No weapon info '{info}'")
def remove_multi_level(userid): # Check validity if es.exists('userid', userid): # Reset player speed and gravity getPlayer(userid).speed = 1.0 gravity.removeGravityChange(userid) # Get the Player() object ggPlayer = Player(userid) # Remove the ent indexes while ggPlayer.multiLevelEntities: ind = ggPlayer.multiLevelEntities.pop() # Create entitylists for the sparks validIndexes = es.getEntityIndexes('env_spark') # If the saved index of the index given to the player still exists # remove it. if ind in validIndexes: spe.removeEntityByIndex(ind) # Stop the sound es.stopsound(userid, currentMultiLevel[userid]) # Remove the player from the current multi level list del currentMultiLevel[userid]
def remove_multi_level(userid): # Check validity if es.exists('userid', userid): # Reset player speed and gravity getPlayer(userid).speed = 1.0 gravity.removeGravityChange(userid) # Get the Player() object ggPlayer = Player(userid) # Remove the ent indexes while ggPlayer.multiLevelEntities: ind = ggPlayer.multiLevelEntities.pop() # Create entitylists for the sparks validIndexes = es.getEntityIndexes('env_spark') # If the saved index of the index given to the player still exists # remove it. if ind in validIndexes: spe.removeEntityByIndex(ind) # Stop the sound es.stopsound(userid, currentMultiLevel[userid]) # Remove the player from the current multi level list del currentMultiLevel[userid]
def player_death(event_var): # Find the number of hostages following the victim handle = es.getplayerhandle(event_var['userid']) hostages = len(filter(lambda index: es.getindexprop(index, 'CHostage.m_leader') == handle, es.getEntityIndexes('hostage_entity'))) # Were any hostages following? if not hostages: return # Was suicide? attacker = int(event_var['attacker']) if not attacker: return # Was a team kill? if event_var['es_userteam'] == event_var['es_attackerteam']: return # Get the attacker instance ggPlayer = Player(attacker) # Increment player hostage stops ggPlayer.hostage_stopped += hostages # Enough hostages stopped to level player up? if ggPlayer.hostage_stopped >= int(gg_hostage_stopped_stops): # Decrease the hostage stopped counter ggPlayer.hostage_stopped -= int(gg_hostage_stopped_stops) # The number of levels we will level up the player levels = 1 # If they shouldn't be skipping their current level, stop here if (not int(gg_hostage_stopped_skip_nade) and ggPlayer.weapon == 'hegrenade') or ( not int(gg_hostage_stopped_skip_knife) and ggPlayer.weapon == 'knife'): msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping', {'level': ggPlayer.weapon}) return # Loop through weapons of the levels we plan to level the player past for weapon in getLevelupList(ggPlayer.level, ggPlayer.level + int(gg_hostage_stopped_levels)): # If gg_hostage_stopped_skip_knife or gg_hostage_stopped_skip_nade # are disabled, make sure the player will not skip that level if (not int(gg_hostage_stopped_skip_knife) and weapon == 'knife') or ( not int(gg_hostage_stopped_skip_nade) and weapon == 'hegrenade'): msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping', {'level': weapon}) break # Add to the number of levels they will gain levels += 1 ggPlayer.levelup(levels, 0, 'hostage_stopped')
def disable_objectives(): '''Disables Objectives on the map''' # Get a userid userid = es.getuserid() # Is there a userid on the server? if not userid: # If not, es_xfire cannot be ran, so simply return return # Get map info map_objectives = int(gg_map_obj) # Set up the command to format cmd = '' # Do Bombing Objectives need removed? if map_objectives in (1, 2): # Are there any func_bomb_target indexes if len(es.getEntityIndexes('func_bomb_target')): # Disable all func_bomb_target entities cmd += 'es_xfire %d func_bomb_target Disable;' % userid # Kill all weapon_c4 entities cmd += 'es_xfire %d weapon_c4 Kill;' % userid # Do Hostage Objectives need removed? if map_objectives in (1, 3): # Are there any func_hostage_rescue indexes? if len(es.getEntityIndexes('func_hostage_rescue')): # Disable all func_hostage_rescue entities cmd += 'es_xfire %d func_hostage_rescue Disable;' % userid # Kill all hostage_entity entities cmd += 'es_xfire %d hostage_entity Kill;' % userid # Is there a command string? if cmd: # Execute the command string to disable objectives es.server.queuecmd(cmd)
def disable_objectives(): '''Disables Objectives on the map''' # Get a userid userid = es.getuserid() # Is there a userid on the server? if not userid: # If not, es_xfire cannot be ran, so simply return return # Get map info map_objectives = int(gg_map_obj) # Set up the command to format cmd = '' # Do Bombing Objectives need removed? if map_objectives in (1, 2): # Are there any func_bomb_target indexes if len(es.getEntityIndexes('func_bomb_target')): # Disable all func_bomb_target entities cmd += 'es_xfire %d func_bomb_target Disable;' % userid # Kill all weapon_c4 entities cmd += 'es_xfire %d weapon_c4 Kill;' % userid # Do Hostage Objectives need removed? if map_objectives in (1, 3): # Are there any func_hostage_rescue indexes? if len(es.getEntityIndexes('func_hostage_rescue')): # Disable all func_hostage_rescue entities cmd += 'es_xfire %d func_hostage_rescue Disable;' % userid # Kill all hostage_entity entities cmd += 'es_xfire %d hostage_entity Kill;' % userid # Is there a command string? if cmd: # Execute the command string to disable objectives es.server.queuecmd(cmd)
def loadRandomPoints(userid): # Remove existing spawnpoints for tSpawn in es.getEntityIndexes('info_player_terrorist'): es.server.cmd('es_xremove %s' % tSpawn) for ctSpawn in es.getEntityIndexes('info_player_counterterrorist'): es.server.cmd('es_xremove %s' % ctSpawn) # Loop through the spawnpoints for spawn in spawnPoints: for team in ('info_player_terrorist', 'info_player_counterterrorist'): # Create the spawnpoint and get the index index = spe.getIndexOfEntity(spe.giveNamedItem(userid, team)) # Set the spawnpoint position and rotation es.setindexprop(index, 'CBaseEntity.m_vecOrigin', '%s,%s,%s' % (spawn[0], spawn[1], spawn[2])) es.setindexprop(index, 'CBaseEntity.m_angRotation', '0,%s,0' % spawn[4])
def loadRandomPoints(userid): # Remove existing spawnpoints for tSpawn in es.getEntityIndexes('info_player_terrorist'): es.server.cmd('es_xremove %s' % tSpawn) for ctSpawn in es.getEntityIndexes('info_player_counterterrorist'): es.server.cmd('es_xremove %s' % ctSpawn) # Loop through the spawnpoints for spawn in spawnPoints: for team in ('info_player_terrorist', 'info_player_counterterrorist'): # Create the spawnpoint and get the index index = spe.getIndexOfEntity(spe.giveNamedItem(userid, team)) # Set the spawnpoint position and rotation es.setindexprop(index, 'CBaseEntity.m_vecOrigin', '%s,%s,%s' % (spawn[0], spawn[1], spawn[2])) es.setindexprop(index, 'CBaseEntity.m_angRotation', '0,%s,0' % spawn[4])
def player_spawn(event_var): '''Called any time a player spawns''' userid = int(event_var['userid']) # Is a spectator? if int(event_var['es_userteam']) < 2: return # Is player dead? if getPlayer(userid).isdead: return ggPlayer = Player(userid) # Do we need to give the player a defuser? if int(gg_player_defuser): # Is the player a CT? if int(event_var['es_userteam']) == 3: # Are we removing bomb objectives from map? if not int(gg_map_obj) in (1, 2): # Does the map have a bombsite? if len(es.getEntityIndexes('func_bomb_target')): # Does the player already have a defuser? if not getPlayer(userid).defuser: # Give the player a defuser: getPlayer(userid).defuser = 1 # Strip bots (sometimes they keep previous weapons) if es.isbot(userid): delayed(0.25, give_weapon_check, (userid)) delayed(0.35, ggPlayer.strip) # Player is human else: # Reset AFK delayed(0.60, ggPlayer.afk.reset) # Give the player their weapon delayed(0.05, give_weapon_check, (userid))
def HG_Trail(uid): handle = es.getplayerhandle(uid) index = 0 for index in es.getEntityIndexes('hegrenade_projectile'): if handle == es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity'): spe_effects.beamFollow( '#all', # users 0., # fDelay index, # iEntityIndex 'sprites/laser.vmt', # szModelPath 1, # iHaloIndex 0.5, # fLife 16, # fWidth 4, # fEndWidth 0, # fFadeLength 0, # iRed 255, # iGreen 0, # iBlue 255, # iAlpha )
def HG_Trail(uid): handle = es.getplayerhandle(uid) index = 0 for index in es.getEntityIndexes('hegrenade_projectile'): if handle == es.getindexprop(index, 'CBaseEntity.m_hOwnerEntity'): spe_effects.beamFollow( '#all', # users 0., # fDelay index, # iEntityIndex 'sprites/laser.vmt', # szModelPath 1, # iHaloIndex 0.5, # fLife 16, # fWidth 4, # fEndWidth 0, # fFadeLength 0, # iRed 255, # iGreen 0, # iBlue 255, # iAlpha )
def cmd_spawn_show(args=None): userid = es.getuserid() # If there are no players on the map, stop here if not userid: return # If spawnpoints are currently being shown, toggle them off and stop here if len(propIndexes): entityIndexes = es.getEntityIndexes("prop_dynamic") for index in propIndexes: if propIndexes[index] in entityIndexes: es.server.cmd("es_xremove gg_sp_prop%i" % int(index)) propIndexes.clear() return # Loop through the spawnpoints count = 0 for spawnPoint in read_spawn_points(): spawnPoint = spawnPoint.strip("\n") location = [] angle = [] location.extend(spawnPoint.split(" ")[0:3]) angle.extend(spawnPoint.split(" ")[3:6]) # Create prop and name it playerView = getPlayer(userid).get("viewangle") es.server.cmd("es_xprop_dynamic_create %s %s" % (userid, propModel)) es.server.cmd("es_xentsetname %s gg_sp_prop%i" % (userid, count)) es.server.cmd("es_xsetang %i %f %f" % (userid, playerView[0], playerView[1])) # Get index propIndex = int(es.ServerVar("eventscripts_lastgive")) # Set position and collision group es.setindexprop(propIndex, "CBaseEntity.m_CollisionGroup", 2) es.setindexprop(propIndex, "CBaseEntity.m_vecOrigin", "%s, %s, %s" % (location[0], location[1], location[2])) es.setindexprop(propIndex, "CBaseEntity.m_angRotation", "0, %s, 0" % angle[1]) # Set aestetics es.server.cmd('es_xfire %s ' % userid + 'prop_dynamic SetAnimation "walk_lower"') es.server.cmd('es_xfire %s ' % userid + 'prop_dynamic SetDefaultAnimation "walk_lower"') es.server.cmd('es_xfire %s ' % userid + 'prop_dynamic AddOutput "rendermode 1"') es.server.cmd('es_xfire %s prop_dynamic alpha "160"' % userid) # Add to prop index points propIndexes[count] = propIndex count += 1 # If there were no spawnpoitns to be shown, tell them if count == 0: es.dbgmsg(0, langstring("OperationFailed:NoSpawnpoints"))
def player_death(event_var): # Find the number of hostages following the victim handle = es.getplayerhandle(event_var['userid']) hostages = len( filter( lambda index: es.getindexprop(index, 'CHostage.m_leader') == handle, es.getEntityIndexes('hostage_entity'))) # Were any hostages following? if not hostages: return # Was suicide? attacker = int(event_var['attacker']) if not attacker: return # Was a team kill? if event_var['es_userteam'] == event_var['es_attackerteam']: return # Get the attacker instance ggPlayer = Player(attacker) # Increment player hostage stops ggPlayer.hostage_stopped += hostages # Enough hostages stopped to level player up? if ggPlayer.hostage_stopped >= int(gg_hostage_stopped_stops): # Decrease the hostage stopped counter ggPlayer.hostage_stopped -= int(gg_hostage_stopped_stops) # The number of levels we will level up the player levels = 1 # If they shouldn't be skipping their current level, stop here if (not int(gg_hostage_stopped_skip_nade) and ggPlayer.weapon == 'hegrenade') or (not int(gg_hostage_stopped_skip_knife) and ggPlayer.weapon == 'knife'): msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping', {'level': ggPlayer.weapon}) return # Loop through weapons of the levels we plan to level the player past for weapon in getLevelupList( ggPlayer.level, ggPlayer.level + int(gg_hostage_stopped_levels)): # If gg_hostage_stopped_skip_knife or gg_hostage_stopped_skip_nade # are disabled, make sure the player will not skip that level if (not int(gg_hostage_stopped_skip_knife) and weapon == 'knife') or (not int(gg_hostage_stopped_skip_nade) and weapon == 'hegrenade'): msg(ggPlayer.userid, 'CannotSkipLevel_ByStopping', {'level': weapon}) break # Add to the number of levels they will gain levels += 1 ggPlayer.levelup(levels, 0, 'hostage_stopped')