View Single Post
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