Raised This Month: $35 Target: $400
 8% 

SourceHook compile errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
client21
Member
Join Date: Apr 2013
Old 06-04-2018 , 03:17   SourceHook compile errors
Reply With Quote #1

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 is offline
client21
Member
Join Date: Apr 2013
Old 06-04-2018 , 04:31   Re: SourceHook compile errors
Reply With Quote #2

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 is offline
client21
Member
Join Date: Apr 2013
Old 06-04-2018 , 04:40   Re: SourceHook compile errors
Reply With Quote #3

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.

Last edited by client21; 06-04-2018 at 04:40.
client21 is offline
client21
Member
Join Date: Apr 2013
Old 06-04-2018 , 04:51   Re: SourceHook compile errors
Reply With Quote #4

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.

Last edited by client21; 06-04-2018 at 05:20.
client21 is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 06-04-2018 , 06:52   Re: SourceHook compile errors
Reply With Quote #5

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.
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:53.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode