27.05.2010, 16:35
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:
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:
Then, if the value of the variable "id" is 2,I will get the remaining parameters by sscanf again:
That's it!
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
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;
Код:
case 2: { if(!sscanf(timestring,"ii",hour,minute) //do something } } }