assi
1
I am using zconsole with some custom commands. In order to read the arguments passed to with the command, I am using the
state->command
buffer, but all I get is the name of the commands.
What am I missing? How do I retrieve the parameters passed with the command?
This is an example of a custom command:
int mycommand(ConsoleState* state)
{
// mycommand 2 2000
auto int temp;
char* pParam;
int i;
long lTimeout;
// Check to make sure the command has 2 parameters
if(state->commandparams != 2)
{
state->error = CON_ERR_BADPARAMETER;
return -1;
}
temp = state->numparams - state->commandparams;
// Check 1st parameter (nr)
pParam = con_getparam(state->command, temp);
i = atoi(pParam);
if(i > 10)
{
state->error = CON_ERR_BADPARAMETER;
return -1;
}
// Check 2nd parameter (timeout in milliseconds)
pParam = con_getparam(state->command, temp + 1);
lTimeout = atol(pParam);
// Backup the new timeout values...
con_backup();
return 1;
}