Raised This Month: $51 Target: $400
 12% 

how can i hook void ClientCommand


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
thresh
New Member
Join Date: Mar 2015
Old 04-21-2015 , 04:43   how can i hook void ClientCommand
Reply With Quote #1

Hello,
I try
void ClientCommand(edict_t *pEntity)
{
SERVER_PRINT("HALLO");
}
but it doesnt work. How can i hook all send to client commands on metamod plugin ?
thresh is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-21-2015 , 07:36   Re: how can i hook void ClientCommand
Reply With Quote #2

How do you register it?
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
thresh
New Member
Join Date: Mar 2015
Old 04-21-2015 , 10:19   Re: how can i hook void ClientCommand
Reply With Quote #3

I did not registered anything.

I'am trying catch all commands on server.
Sry,i'am newbie on metamod/c++.

I just want catch all amxmodx client_cmd, console_cmd function argvs.
Like ;
If some plugin send to player client_cmd(id,"say i'am n00b"); i catch it.
sry for my english
thanks
thresh is offline
Bos93
Veteran Member
Join Date: Jul 2010
Old 04-21-2015 , 14:41   Re: how can i hook void ClientCommand
Reply With Quote #4

You need hook function from engine, PF_stuffcmd_I.
__________________
Bos93 is offline
Send a message via ICQ to Bos93 Send a message via Skype™ to Bos93
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-21-2015 , 19:06   Re: how can i hook void ClientCommand
Reply With Quote #5

PHP Code:
// VOID = void
// PENTITY = edict_t *
// CPCHAR = const char *
// MAX_ARGS = 1024
// SIZE_T = size_t
// #include <string> // std::string
// ISPLR = #define ISPLR(PlrId) (PlrId >= 1 && PlrId <= gpGlobals->maxClients)
// g_pMetaGlobalVars->Result = Result; = RETURN_META(Result);

// CLIENT SENDS COMMAND
//
VOID onClientCommand(PENTITY pEntity)
{
    
// ARGUMENTS HANDLE
    //
    
static CPCHAR pArgs[MAX_ARGS];

    
// GETS CLIENT ID
    //
    
SIZE_T entityId g_engFuncs.pfnIndexOfEdict(pEntity);

    
// METAMOD RESULT
    //
    
METARESULT Result MRES_IGNORED;

    
// ARGUMENTS STRING (NO COMMAND)
    //
    
std::string argStr "";

    
// VALID PLAYER
    //
    
if (ISPLR(entityId))
    {
        
// ARGUMENTS COUNT
        //
        
SIZE_T argsCount g_engFuncs.pfnCmdArgc();

        
// ARGUMENTS HAVE PASSED
        
if (argsCount 0)
        {
            
// ITERATES BETWEEN ARGUMENTS
            //
            
for (SIZE_T Iterator 0Iterator argsCountIterator++)
            {
                
// FILLS UP pArgs
                
pArgs[Iterator] = g_engFuncs.pfnCmdArgv(Iterator);

                
// NO MORE VALIDITY CHECKS
                // IT'S KNOWN HOW MANY ARGUMENTS HAVE PASSED
                // SKIPS COMMAND NAME AS WELL
                //
                
if (Iterator 0)
                {
                    
// APPEND ARGUMENT TO STRING
                    //
                    
argStr += pArgs[Iterator];

                    
// ADDS SPACE IF NEEDED (UNTIL THE LAST ARGUMENT IS REACHED)
                    //
                    
if (Iterator != argsCount 1)
                        
argStr += " ";
                };
            };

            
// ITERATES BETWEEN COMMANDS
            //
            
for (SIZE_T Iterator 0Iterator g_cmdsMan.Size(); Iterator++)
            {
                
// CASE INSENSITIVE
                //
                
if (stricmp(g_cmdsMan.m_Cmds.at(Iterator).m_Name.c_str(), pArgs[0]) == 0)
                {
                    
// EXECUTES
                    //
                    
g_cmdsMan.Exec(IteratorpEntityentityIdargsCountpArgsargStr);

                    
// SUPERCEDES
                    //
                    
g_pMetaGlobalVars->Result MRES_SUPERCEDE;
                    return;
                };
            };

            
// MENUS
            //
            
if (stricmp(pArgs[0], "MenuSelect") == && pArgs[1] && g_Plr[entityId].menuId != INVALID_NUMBER)
            {
                
// GETS ITEM ID
                
SIZE_T ItemID atoi(pArgs[1]) - 1;

                
// CHECKS IF MENU HAS THAT ITEM
                //
                
if (g_menusMan.m_Menus.at(g_Plr[entityId].menuId).m_Keys & (<< ItemID))
                {
                    
// EXECUTES
                    //
                    
g_menusMan.Exec(entityIdg_Plr[entityId].menuIdItemID);

                    
// PLAYER HAS NO LONGER MENU
                    //
                    
g_Plr[entityId].menuId INVALID_NUMBER;
                };
            };

            
// SAY COMMAND
            //
            
if (stricmp(pArgs[0], "Say") == 0)
            {
                
// VALID ARGUMENT
                //
                
if (pArgs[1])
                {

                };
            };
        };
    };

    
// SETS RESULT AND QUIT
    //
    
g_pMetaGlobalVars->Result Result;
}; 
Also consider Bos93's post.
And don't forget about moduleconfig.h, uncomment (remove '//') from the front of ClientCommand...
__________________

Last edited by claudiuhks; 04-21-2015 at 21:32.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
hzqst
Senior Member
Join Date: Jul 2008
Old 04-21-2015 , 19:38   Re: how can i hook void ClientCommand
Reply With Quote #6

Some commands don't go through ClientCommand, like "slot1~10", "screenshot", "quit", "connect","retry"
they are handled client-side,


see claudiuhks's reply.

Last edited by hzqst; 04-21-2015 at 21:24.
hzqst is offline
thresh
New Member
Join Date: Mar 2015
Old 04-22-2015 , 01:46   Re: how can i hook void ClientCommand
Reply With Quote #7

Thank you guys i will try it
thresh is offline
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 12:25.


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