Thank you for the instant help, guys. Nice that the addon supports these things directly from user-level scripts, as I doubted since SM doesn't support these from scripts, for example (only through C++ extensions).
I've properly installed Source.Py in my server and started to code first bits around this hook for what I want to achieve, thanks to @L'In20Cible sample. However, I'm getting the following error when the interface load executes:
Code: Select all
pluginHelpers = get_interface('server', 'PluginHelpersCheck001')
ValueError: Unable to load library 'server'
How to solve it? For info, the server app is HL2:DM
UPDATE: This works instead:
Code: Select all
pluginHelpers = get_interface('hl2mp/bin/server_srv.so', 'PluginHelpersCheck001')
Isn't SP able to translate
'server' or even
'server_srv' to the relative mod's binary path? Similar thing happens when trying to get the engine iface (only
'engine_srv.so' works, note I don't have to prefix any bin directory to it as SP seems to already include the base bin directory in its own search path, or whatever) - May this be considerable an issue to correct/enhance at the SP core?
Another issue, by the way, from my temporary current relevant code:
Code: Select all
pluginHelpers = get_interface('hl2mp/bin/server_srv.so', 'PluginHelpersCheck001')
createMessageFn = pluginHelpers.make_virtual_function(0, Convention.THISCALL,
# this, plugin, player edict, dialog type, data (KeyValues)
(DataType.POINTER, DataType.STRING, DataType.POINTER, DataType.INT, DataType.POINTER), DataType.BOOL)
@PreHook(createMessageFn)
def pre_create_message(args):
edict = edict_from_pointer(args[2])
player = Player(index_from_edict(edict))
type = DialogType(args[3])
print("Sending dialog of type = ", type)
Produces:
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/pluginmessages_helper/pluginmessages_helper.py", line 16, in pre_create_message
player = Player(index_from_edict(args[2]))
Boost.Python.ArgumentError: Python argument types in
_entities._helpers.index_from_edict(Pointer)
did not match C++ signature:
index_from_edict(edict_t* Edict)
I tried to replace the line by the following, according from what I could understand from the API:
Code: Select all
edict = edict_from_pointer(args[2])
player = Player(index_from_edict(edict))
But this error happens instead:
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/plugins/pluginmessages_helper/pluginmessages_helper.py", line 16, in pre_create_message
edict = edict_from_pointer(args[2])
ValueError: Conversion from "Pointer" (<_memory.Pointer object at 0xea7e61d0>) to "Edict" failed.
I'd appreciate your help, I want to learn this advanced stuff regardless of my final goal. Thank you.