Thread: [Solved] SH_ADD_HOOK Don't work.
View Single Post
Author Message
201724
Member
Join Date: May 2011
Old 04-06-2020 , 03:27   SH_ADD_HOOK Don't work.
Reply With Quote #1

Code:
bool MetaProtect::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
    ConMsg("SDK_OnMetamodLoad\n");

    gpGlobals = ismm->GetCGlobals();

	GET_V_IFACE_CURRENT(GetEngineFactory, helpers, IServerPluginHelpers, INTERFACEVERSION_ISERVERPLUGINHELPERS);
	GET_V_IFACE_CURRENT(GetEngineFactory, icvar, ICvar, CVAR_INTERFACE_VERSION);
	GET_V_IFACE_ANY(GetServerFactory, gameclients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS);
	GET_V_IFACE_ANY(GetServerFactory, playerinfomanager, IPlayerInfoManager, INTERFACEVERSION_PLAYERINFOMANAGER);

    ConMsg("[!!!!!!!!!!!!!!!!!]gameclients:%p\n",gameclients);
    ConMsg("[!!!!!!!!!!!!!!!!!]playerinfomanager:%p\n",playerinfomanager);
    ConMsg("[!!!!!!!!!!!!!!!!!]helpers:%p\n",helpers);
    g_pCVar = icvar;
    ConVar_Register(0, &s_BaseAccessor);
    
    SH_ADD_HOOK(IServerGameClients, ClientConnect, gameclients, SH_MEMBER(this, &MetaProtect::OnClientConnect), false);
    SH_ADD_HOOK(IServerGameClients, ClientConnect, gameclients, SH_MEMBER(this, &MetaProtect::OnClientConnect_Post), true);
    SH_ADD_HOOK(IServerGameClients, ClientCommand, gameclients, SH_MEMBER(this, &MetaProtect::OnClientCommand), false);

    SH_ADD_HOOK(IServerGameClients, ClientPutInServer, gameclients, SH_MEMBER(this, &MetaProtect::OnClientPutInServer), true);
    SH_ADD_HOOK(IServerGameClients, ClientDisconnect, gameclients, SH_MEMBER(this, &MetaProtect::OnClientDisconnect), false);
    SH_ADD_HOOK(IServerGameClients, ClientDisconnect, gameclients, SH_MEMBER(this, &MetaProtect::OnClientDisconnect_Post), true);

    return true;
}
When I installed these hooks on the csgo server, he didn't get the correct call? I don't know why. Do you need to add additional processing?


It was I who modified the interface function of mmsource that caused the interface error. I restored it and worked it out.

Last edited by 201724; 04-06-2020 at 04:00.
201724 is offline
Send a message via MSN to 201724