Hello! I'm studying the possibilities of Metamod, and I was wondering if it was possible to intercept the call of the function IBaseFileSystem::Open and call it with another parameter? I was trying to do this:
PHP Code:
SH_DECL_HOOK3(IBaseFileSystem, Open, SH_NOATTRIB, 0, FileHandle_t, const char *, const char *, const char *);
I announced this
PHP Code:
IBaseFileSystem *basefilesystem = NULL;
GET_V_IFACE_CURRENT(GetFileSystemFactory, basefilesystem, IBaseFileSystem, BASEFILESYSTEM_INTERFACE_VERSION);
and add hook
PHP Code:
OpenHook = SH_ADD_VPHOOK(IBaseFileSystem, Open, basefilesystem, SH_MEMBER(this, &SamplePlugin::Hook_Open), false);
I tried to do so
PHP Code:
FileHandle_t SamplePlugin::Hook_Open(const char *pFileName, const char *pOptions, const char *pathID) {
if(strncmp(pFileName, "materials/headshot1.vtf", strlen("materials/headshot1.vtf")) == 0) {
META_LOG(g_PLAPI, "yeaaa opening headshot file \"%s\",pOptions \"%s\",pathID \"%s\".", pFileName, pOptions, pathID);
RETURN_META_VALUE_NEWPARAMS(MRES_OVERRIDE, NULL, &IBaseFileSystem::Open, ("materials/headshot2.vtf", pOptions, pathID));
}
RETURN_META_VALUE(MRES_IGNORED, false);
}
but not working((
If you do like this, the server is crashing
PHP Code:
FileHandle_t SamplePlugin::Hook_Open(const char *pFileName, const char *pOptions, const char *pathID) {
if(strncmp(pFileName, "materials/headshot1.vtf", strlen("materials/headshot1.vtf")) == 0) {
META_LOG(g_PLAPI, "yeaaa opening headshot file \"%s\",pOptions \"%s\",pathID \"%s\".", pFileName, pOptions, pathID);
FileHandle_t myhndl = basefilesystem->Open(pFileName, pOptions, pathID);
RETURN_META_VALUE(MRES_SUPERCEDE, myhndl);
}
RETURN_META_VALUE(MRES_IGNORED, false);
}
What did I do wrong? I tried using MRES_OVERRIDE, but it did not help...