[SOLVED]Different no.of parameters read depends on the 1st parameter in sscanf? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED]Different no.of parameters read depends on the 1st parameter in sscanf? (
/showthread.php?tid=150722)
[SOLVED]Different no.of parameters read depends on the 1st parameter in sscanf? -
hk_shade - 27.05.2010
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!
Re: Different no.of parameters read depends on the 1st parameter in sscanf? -
hk_shade - 28.05.2010
Is there any suggestion for this problem?Thanks.