AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   Solved SH_ADD_HOOK Don't work. (https://forums.alliedmods.net/showthread.php?t=322867)

201724 04-06-2020 03:27

SH_ADD_HOOK Don't work.
 
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.


All times are GMT -4. The time now is 08:07.

Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.