Thanks for the quick replies! Sadly, it's still crashing. I'm trying to get the player that used a
func_button to trigger something else (in this case a func_door).
I tried using the OnEntityOutput listener for this, but it doesn't trigger for some entities. So I thought I should hook the input instead. This is my test code:
Syntax: Select all
# ../door_test/door_test.py
# Source.Python
from entities.hooks import EntityPreHook, EntityCondition
is_door = EntityCondition.equals_entity_classname('func_door')
@EntityPreHook(is_door, 'accept_input')
def pre_accept_input(stack_data):
print(stack_data)
Without setting the convention in the .ini file, I get the following error:
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\plugins\door_test\door_test.py", line 12, in pre_accept_input
print(stack_data)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd9 in position 2: invalid continuation byte
ESP not present.
If I set the convention, I get two errors:
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\memory\helpers.py", line 144, in as_conventio
n
return Convention.names[value]
KeyError: 'thiscall'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\plugins\command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "..\addons\source-python\packages\source-python\plugins\manager.py", line 194, in load
plugin._load()
File "..\addons\source-python\packages\source-python\plugins\instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "..\addons\source-python\plugins\door_test\door_test.py", line 10, in <module>
@EntityPreHook(is_door, 'accept_input')
File "..\addons\source-python\packages\source-python\entities\hooks.py", line 129, in __call__
if self.initialize(entity):
File "..\addons\source-python\packages\source-python\entities\hooks.py", line 162, in initialize
self.hooked_function = getattr(entity, self.function)
File "..\addons\source-python\packages\source-python\entities\_base.py", line 107, in __getattr__
for server_class in self.server_classes:
File "..\addons\source-python\packages\source-python\entities\_base.py", line 244, in server_class
es
yield from server_classes.get_entity_server_classes(self)
File "..\addons\source-python\packages\source-python\entities\classes.py", line 198, in get_entity
_server_classes
datamap=entity_datamaps.get(class_name, {}),
File "..\addons\source-python\packages\source-python\entities\classes.py", line 232, in _get_serve
r_class
instance = self.create_type_from_file(class_name, manager_contents)
File "..\addons\source-python\packages\source-python\memory\manager.py", line 342, in create_type_
from_file
type_name, GameConfigObj(f), bases)
File "..\addons\source-python\packages\source-python\memory\manager.py", line 413, in create_type_
from_dict
for name, data in vfuncs:
File "..\addons\source-python\packages\source-python\memory\helpers.py", line 397, in parse_data
value if value is default else converter(manager, value))
File "..\addons\source-python\packages\source-python\memory\helpers.py", line 146, in as_conventio
n
return manager.custom_conventions[value]
KeyError: 'thiscall'
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File "..\addons\source-python\packages\source-python\entities\hooks.py", line 227, in on_entity_cr
eated
_waiting_entity_hooks.initialize(base_entity.index)
File "..\addons\source-python\packages\source-python\entities\hooks.py", line 212, in initialize
if hook.initialize(entity):
File "..\addons\source-python\packages\source-python\entities\hooks.py", line 162, in initialize
self.hooked_function = getattr(entity, self.function)
File "..\addons\source-python\packages\source-python\entities\_base.py", line 116, in __getattr__
raise AttributeError('Attribute "{0}" not found'.format(attr))
AttributeError: Attribute "accept_input" not found