[Hldms] Entity remover, to remove "doubles"

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
Junior Member
Posts: 13
Joined: Mon Jun 29, 2015 1:20 am

[Hldms] Entity remover, to remove "doubles"

Postby hugo5511 » Thu Jun 14, 2018 2:41 am

I was hoping for Valve to get around to fix some things they broke during the Steampipe update (fall 2013) five years later still broke.
The main big problem is with entity's, they are all doubled door's,glass,healthkits,ect,ect
This break's level's with thing's like fans,lifts,rotating door's.

Any idea's on a script that may fix this,Sourcemod has a Stripper2 that is reported to fix this issue but that's Sourcemod on Linux

I still use Eventscripts,on windows, still work's great with 15 script's running 24/7, I would be great if a plug in played nice with it's older brother (ES) :smile:

User avatar
Project Leader
Posts: 1049
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [Hldms] Entity remover, to remove "doubles"

Postby L'In20Cible » Thu Jun 14, 2018 3:34 am

You could try that: https://github.com/Ayuto/EventScripts-Emulator

Or you could post the ES codes you are using in the Plugin Requests section and someone might be able to convert them to SP.
User avatar
Project Leader
Posts: 1838
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [Hldms] Entity remover, to remove "doubles"

Postby Ayuto » Thu Jun 14, 2018 6:10 am

No need to use the emulator. EventScripts and Source.Python can be run at the same time on Windows.
Junior Member
Posts: 13
Joined: Mon Jun 29, 2015 1:20 am

Re: [Hldms] Entity remover, to remove "doubles"

Postby hugo5511 » Fri Jun 15, 2018 2:19 am

Here is a link to the sourcemod plugin that work's for this problem would be great if someone here could take a peek and convert to ES or SP now that is know they "play well together"


User avatar
Global Moderator
Posts: 125
Joined: Wed Aug 15, 2012 1:24 am
Location: Germany

Re: [Hldms] Entity remover, to remove "doubles"

Postby Kami » Fri Jun 15, 2018 11:12 pm

I think Half Life Deathmatch - Source is not supported by SourcePython currently.


I tried to write an Eventscripts plugin to do what you want:

Syntax: Select all

import es
import corelib
import gamethread

ent_dict = {}
remove_list = {}

def es_map_start(ev):

def do_it():
#Put all entities in a dictionary and assign the location to its index. Structure: Classname -> Index -> Location
remove_list = {}
ents = es.createentitylist()
for ent in ents:
class_name = ents[ent]['classname']
if class_name not in ent_dict:
ent_dict[class_name] = {}
loc = es.getindexprop(ent, 'CBaseEntity.m_vecOrigin')
if str(loc) == "0.000000,0.000000,0.000000":
loc = es.getindexprop(ent, 'CBaseEntity.m_Collision.m_vecMins')
ent_dict[class_name][ent] = loc

#Put entities in the remove_list only if the location is not used yet.
for class_name in ent_dict:
#ent_dict[class_name] = entity index

#Check if the class_name was assigned to the remove_list before
if class_name not in remove_list:

#If not, assign it an empty dictionary to keep all entities with the same name but with different location
remove_list[class_name] = []

#Loop through all the locations for that given classname
for loc in ent_dict[class_name]:

#If the location is not in the remove_dict already add it, if it is, remove the entity
if ent_dict[class_name][loc] not in remove_list[class_name]:
if str(ent_dict[class_name][loc]) != "0.000000,0.000000,0.000000":

I have not done ES:P in a while so I highly doubt this is the best way to do it. But you can check it out and see if it works for you :)

The biggest problem are the windows (func_breakable_surf), as their origin always returns 0,0,0 so if I compare them by that every window gets removed. That's why a collision vector is used for entities that have an origin of 0,0,0. That could possibly be a cause for problems too.
User avatar
Project Leader
Posts: 1838
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [Hldms] Entity remover, to remove "doubles"

Postby Ayuto » Wed Jun 20, 2018 8:38 pm

I guess the hl2dm build will also work for hldms.

Just in case anyone needs it or wants to elaborate it a little bit more, here is "Stripper Lite". :grin:

Syntax: Select all

# =============================================================================
# =============================================================================
import shlex

from memory import get_virtual_function
from memory.hooks import PreHook
from engines.server import engine_server
from engines.server import server_game_dll

# =============================================================================
# =============================================================================
# Tested in CS:S on cs_office

def handle_entity(props):
"""Return ``True`` to add the entity, ``False`` to remove it.

You can also modify the entity's properties. Don't forget to return ``True``
in that case as well.
# EXAMPLE: Removing entities
# Window?
if get_property(props, 'classname') == 'func_breakable_surf':
# Don't add windows
return False

# EXAMPLE: Modifying entities
# CT spawn?
if get_property(props, 'classname') == 'info_player_counterterrorist':
# Get the current origin, increase the Z axis by 100 units and set it
origin = list(map(float, get_property(props, 'origin').split(' ')))
origin[2] += 100
set_property(props, 'origin', ' '.join(map(str, origin)))

# Add all other entities
return True

def add_entities(entities):
"""Add entities here."""

# Add a new entity by parsing a string. It doesn't care about whitespaces.
"origin" "-1080.348633 -1792.366089 -224.470856"
"classname" "weapon_awp"

# Add an entity by using the list style
('classname', 'weapon_m4a1'),
('origin', '-1080.348633 -1792.366089 -224.470856')

# =============================================================================
# =============================================================================
new_map_entities_string = ''

@PreHook(get_virtual_function(engine_server, 'GetMapEntitiesString'))
def post_get_map_entities_string(args):
return new_map_entities_string

@PreHook(get_virtual_function(server_game_dll, 'LevelInit'))
def pre_level_init(args):
entities = []

for entity in parse_map_entities_string(args[2]):
if handle_entity(entity):

# Ask for new/own entities

# Save the string, so the memory is not invalidated
global new_map_entities_string
new_map_entities_string = build_map_entities_string(entities)
args[2] = new_map_entities_string

def parse_map_entities_string(buffer):
"""Parse a "map entities"-like string and return it as a nested list."""
entities = []
curr_ent = None
for line in buffer.split('\n'):
line = line.strip()

# Skip empty lines
if not line:

if line.startswith('{'):
curr_ent = []
elif line.startswith('}'):
curr_ent = None

return entities

def build_map_entities_string(entities):
"""Create a "map entities"-like string."""
buffer = ''
for ent in entities:
ent_buffer = ''
for key, value in ent:
ent_buffer += f'"{key}" "{value}"\n'

buffer += '{\n%s}\n'% ent_buffer
return buffer

def get_property(props, name):
"""Return the first found property with the given name. An empty string is
returned if the property wasn't found.
for key, value in props:
if key == name:
return value

return ''

def set_property(props, name, value):
"""Change the first found property or add it if missing."""
assert isinstance(value, str)

for prop in props:
if prop[0] == name:
prop[1] = value
# Not found? No problem. Just add it
props.append((name, value))
It requires SP version 654 (currently building).

@Kami: Windows don't seem to use the "origin" property, but these instead:

Code: Select all

"upperright" "-628 -344 -52"
"lowerright" "-628 -344 -148"
"upperleft" "-508 -344 -52"
"lowerleft" "-508 -344 -148"

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 1 guest