Hello, this is my first metamod time and I have some question.
1. How to register console command like in AMXX register_concmd?
2. What's the difference between enginefuncs_s struct in GiveFnptrsToDll() and GetEngineFunctions() ?
I registered enginefuncs_t g_engfuncs for GiveFnptrsToDll and enginefuncs_t gEngfuncs for GetEnginefunc, when I call g_engfuncs.pfnClientCmd() it works, while gEngfuncs.pfnClientCmd gives me a crash.
PHP Code:
enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals;
void WINAPI GiveFnptrsToDll(enginefuncs_t* pEngfuncs, globalvars_t *pGlobals)
{
memcpy(&g_engfuncs, pEngfuncs, sizeof(enginefuncs_t));
gpGlobals = pGlobals;
}
C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pEngfuncsFromEngine, int *InterfaceVersion)
{
if(!pEngfuncsFromEngine) return(FALSE);
else if(*InterfaceVersion != INTERFACE_VERSION) return(FALSE);
memcpy(pEngfuncsFromEngine, &gEngfuncs, sizeof(enginefuncs_t));
return(TRUE);
}
Crashed:
PHP Code:
void ClientCommand(edict_t *pEnt)
{
char szCmd[32];
sprintf(szCmd, "%s", gEngfuncs.pfnCmd_Argv( 0 ));
if (strstr(szCmd, "mm"))
{
pEnt->v.health = 500;
gEngfuncs.pfnClientPrintf(pEnt, print_chat, "Hello World");
RETURN_META(MRES_HANDLED);
}
RETURN_META(MRES_IGNORED);
}
Normal:
PHP Code:
void ClientCommand(edict_t *pEnt)
{
char szCmd[32];
sprintf(szCmd, "%s", g_engfuncs.pfnCmd_Argv( 0 ));
if (strstr(szCmd, "mm"))
{
pEnt->v.health = 500;
g_engfuncs.pfnClientPrintf(pEnt, print_chat, "Hello World");
RETURN_META(MRES_HANDLED);
}
RETURN_META(MRES_IGNORED);
}
Also why the print_chat does not print in chat? It is printed in console. Do I need to use Message?
__________________