added client-based console commands

extended console command functions to have an argument number
renamed Result to Action

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40506
This commit is contained in:
David Anderson
2007-02-16 02:17:41 +00:00
parent dcb10ee3a2
commit 76903cd919
6 changed files with 150 additions and 18 deletions
+20
View File
@@ -342,6 +342,25 @@ static cell_t sm_RegServerCmd(IPluginContext *pContext, const cell_t *params)
return 1;
}
static cell_t sm_RegConsoleCmd(IPluginContext *pContext, const cell_t *params)
{
char *name,*help;
IPluginFunction *pFunction;
pContext->LocalToString(params[1], &name);
pContext->LocalToString(params[3], &help);
pFunction = pContext->GetFunctionById(params[2]);
if (!pFunction)
{
return pContext->ThrowNativeError("Invalid function id (%X)", params[2]);
}
g_ConCmds.AddConsoleCommand(pFunction, name, help, params[4]);
return 1;
}
REGISTER_NATIVES(convarNatives)
{
{"CreateConVar", sm_CreateConVar},
@@ -363,5 +382,6 @@ REGISTER_NATIVES(convarNatives)
{"GetConVarMax", sm_GetConVarMax},
{"ResetConVar", sm_ResetConVar},
{"RegServerCmd", sm_RegServerCmd},
{"RegConsoleCmd", sm_RegConsoleCmd},
{NULL, NULL}
};