AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Coding MM:S Plugins & SM Extensions (https://forums.alliedmods.net/forumdisplay.php?f=75)
-   -   SourceHook compile errors (https://forums.alliedmods.net/showthread.php?t=308031)

client21 06-04-2018 02:17

SourceHook compile errors
 
PHP Code:

class TEST : public SDKExtension
{
public:
    
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismmchar *errorsize_t maxlengthbool late);
    
void Hook_ClientActive(edict_t *pEntitybool bLoadGame);
};

IServerGameClients *gameclients NULL;

TEST g_Test;
SMEXT_LINK(&g_Test);

bool TEST::SDK_OnMetamodLoad(ISmmAPI *ismmchar *errorsize_t maxlengthbool late)
{
    
// Error    2    error C2065: 'id' : undeclared identifier
    
PLUGIN_SAVEVARS();

    
// Error    3    error C2065: 'maxlen' : undeclared identifier
    
GET_V_IFACE_ANY(GetServerFactorygameclientsIServerGameClientsINTERFACEVERSION_SERVERGAMECLIENTS);
    
    
// Error    4    error C3861: '__SourceHook_FHAddIServerGameClientsClientActive': identifier not found
    
SH_ADD_HOOK(IServerGameClientsClientActivegameclientsSH_MEMBER(this, &TEST::Hook_ClientActive), true);
    
    return 
true;
}

void TEST::Hook_ClientActive(edict_t *pEntitybool bLoadGame)
{
    
g_pSM->LogError(myself"Hook_ClientActive(%d, %d)"gamehelpers->IndexOfEdict(pEntity), bLoadGame);


Why?

client21 06-04-2018 03:31

Re: SourceHook compile errors
 
Ok, need this
SH_DECL_HOOK2_void(IServerGameClients, ClientActive, SH_NOATTRIB, 0, edict_t *, bool);

But still error with PLUGIN_SAVEVARS and GET_V_IFACE_ANY.

client21 06-04-2018 03:40

Re: SourceHook compile errors
 
ISmmPlugin.h

#define GET_V_IFACE_ANY(v_factory, v_var, v_type, v_name) \
v_var = (v_type *)ismm->VInterfaceMatch(ismm->v_factory(), v_name, 0); \
if (!v_var) \
{ \
if (error && maxlen) \
{ \
ismm->Format(error, maxlen, "Could not find interface: %s", v_name); \
} \
return false; \
}

Total commander can't find this stupid maxlen var.

client21 06-04-2018 03:51

Re: SourceHook compile errors
 
Ok, when i do this: int maxlen = 1024; then it's work, good help, thx.

---------

#define PLUGIN_SAVEVARS() \
g_SMAPI = ismm; \
g_SHPtr = static_cast<SourceHook::ISourceHook *>(ismm->MetaFactory(MMIFACE_SOURCEHOOK, NULL, NULL)); \
g_PLAPI = static_cast<ISmmPlugin *>(this); \
g_PLID = id;

id = ?
omg, then i must just remove g_PLID = id; ? okay.

asherkin 06-04-2018 05:52

Re: SourceHook compile errors
 
https://github.com/alliedmodders/sou....cpp#L149-L163

2. I don't think you want to be using PLUGIN_SAVEVARS in a MM:S-attached SM extension.
3. This is a problem in the header/function prototype, the maxlength param should be renamed to maxlen, which is what the macro is after.


All times are GMT -4. The time now is 19:49.

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