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

[Metamod] How to Register Console Command


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidJr
Senior Member
Join Date: Apr 2012
Old 04-25-2015 , 01:55   [Metamod] How to Register Console Command
Reply With Quote #1

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_tpEngfuncsglobalvars_t *pGlobals)
{
   
memcpy(&g_engfuncspEngfuncssizeof(enginefuncs_t));

   
gpGlobals pGlobals;
}

C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pEngfuncsFromEngineint *InterfaceVersion
{
    if(!
pEngfuncsFromEngine) return(FALSE);
    else if(*
InterfaceVersion != INTERFACE_VERSION) return(FALSE);

    
memcpy(pEngfuncsFromEngine, &gEngfuncssizeof(enginefuncs_t));
    return(
TRUE);

Crashed:
PHP Code:
void ClientCommand(edict_t *pEnt)
{
    
char szCmd[32];
    
sprintf(szCmd"%s"gEngfuncs.pfnCmd_Argv));

    if (
strstr(szCmd"mm"))
    {
        
pEnt->v.health 500;
        
gEngfuncs.pfnClientPrintf(pEntprint_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));

    if (
strstr(szCmd"mm"))
    {
        
pEnt->v.health 500;
        
g_engfuncs.pfnClientPrintf(pEntprint_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?
__________________
What are you looking for here?

Last edited by DavidJr; 04-25-2015 at 02:00.
DavidJr is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 04-25-2015 , 03:57   Re: [Metamod] How to Register Console Command
Reply With Quote #2

I am not familiar with metamod, but I remember that to print a message to the chat in HLSDK you should use

Code:
ClientPrint(&pEnt->pev, HUD_PRINTTALK, "Hello World");
__________________


Last edited by NiHiLaNTh; 04-25-2015 at 03:58.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Reply



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 23:50.


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