Optional enumerators - 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)
+--- Thread: Optional enumerators - sscanf (
/showthread.php?tid=593163)
Optional enumerators - sscanf -
GranaT3 - 02.11.2015
Hello. I have a problem with a code.
if I put it this code:
pawn Код:
sscanf("1 2 3 4", "E<ii-i-i>(20,30)", quiet_enum);
printf("%i value 1", quiet_enum[value_1]);
printf("%i value 2", quiet_enum[value_2]);
printf("%i value 3", quiet_enum[value_3]);
printf("%i value 4", quiet_enum[value_4]);
That makes what I want, which is to print
20 and
30 in the value 1 and 2.
but I get an error:
sscanf error: Insufficient default values.
I can
fix that mistake, by:
pawn Код:
sscanf("1 2 3 4", "E<ii-i-i>(20,30,40,50)", quiet_enum);
printf("%i value 1", quiet_enum[value_1]);
printf("%i value 2", quiet_enum[value_2]);
printf("%i value 3", quiet_enum[value_3]);
printf("%i value 4", quiet_enum[value_4]);
But I would
1 2 0 0, and not what I want.
How I can fix it ?.
Respuesta: Optional enumerators - sscanf -
GranaT3 - 03.11.2015
anyone?
Re: Optional enumerators - sscanf -
Gammix - 03.11.2015
You should have 3 values there:
Код:
"E<ii-i-i>(20,30,40)"
Because you are updating the first 2 and the last parts of the enum, and remain the 3rd untouched. So sscanf require 3 default values.
You can read this page if you haven't or re-read:
https://sampforum.blast.hk/showthread.php?tid=570927
Respuesta: Re: Optional enumerators - sscanf -
GranaT3 - 03.11.2015
Quote:
Originally Posted by Gammix
You should have 3 values there:
Код:
"E<ii-i-i>(20,30,40)"
Because you are updating the first 2 and the last parts of the enum, and remain the 3rd untouched. So sscanf require 3 default values.
You can read this page if you haven't or re-read: https://sampforum.blast.hk/showthread.php?tid=570927
|
I did, but still prints, "
1-
2-0-0".
pawn Код:
enum tranquilos
{
valor_1,
valor_2,
valor_3,
valor_4
};
new quiet_enum[tranquilos];
// The problem is that the default values are not read.
sscanf("1 2 3 4", "E<ii-i-i>(20, 30, 40)", quiet_enum);
printf("%i value 1", quiet_enum[valor_1]);
printf("%i value 2", quiet_enum[valor_2]);
printf("%i value 3", quiet_enum[valor_3]);
printf("%i value 4", quiet_enum[valor_4]);
You can try if you want.
Respuesta: Optional enumerators - sscanf -
GranaT3 - 03.11.2015
Apparently it's a failure of sscanf. So the solution is:
pawn Код:
sscanf("", "E<ii-i-i>(20, 30, 40)", quiet_enum);
Place empty data. (const data []). There could be "0 0 0 0", and that 0 is also a value.