[SOLVED]Different no.of parameters read depends on the 1st parameter in sscanf?
#1

I am writing a command which uses zcmd and sscanf but I faced some problems.
The command can let users choose what time system they would like to choose,i.e. gtasa time(1 second=1minute)/real time/fixed time.

What I wanted to do is that the first parameter must be entered, and the other parameters are required only for some values of the first parameter.

Here's the client commands that I want to make:
Код:
/timesystem 0
/timesystem 1
/timesystem 2 12 0
I just wanted to do that with sscanf but I don't know how to do that.
Thanks for your help and sorry for my bad English.

_________________________________________________
*The problem was solved by myself.
I first get the parameters by an integer and then an optional string:
Код:
if (!sscanf(params,"iz",id,timestring))
  switch(id)
  {
    case 0: //do something;
    case 1: //do something;
Then, if the value of the variable "id" is 2,I will get the remaining parameters by sscanf again:
Код:
    case 2:
    {
      if(!sscanf(timestring,"ii",hour,minute)
        //do something
    }
  }
}
That's it!
Reply
#2

Is there any suggestion for this problem?Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)