What use is "quiet"? - sscanf -
GranaT3 - 01.11.2015
Hello. What good is this ?:
pawn Код:
new var;
sscanf("42 -100", "{i}i", var);
printf("%i", var);
I do not see an application at that.
Re: Respuesta: Re: What use is "quiet"? - sscanf -
Kevln - 01.11.2015
Quote:
Originally Posted by GranaT3
Yes, but the question is what use?
|
It has a lot of uses, like:
pawn Код:
CMD:command(playerid, cmd[], cmdtext[])
{
new lookupid;
sscanf(cmdtext, "?<CELLMIN_ON_MATCHES=1>U(-1)", lookupid);
if(lookupid == -1)
{
return 1;
}
else if(lookupid == cellmin)
{
return 1;
}
else if(lookupid == INVALID_PLAYER_ID)
{
return 1;
}
else
{
new amount;
if(sscanf(cmdtext, "{i}i", amount)) return 1;
}
return 1;
}
Re: What use is "quiet"? - sscanf -
Kevln - 01.11.2015
It ignores the first integer in the string.
var = -100
Re: What use is "quiet"? - sscanf -
[ABK]Antonio - 01.11.2015
Quote:
Originally Posted by GranaT3
Hello. What good is this ?:
pawn Код:
new var; sscanf("42 -100", "{i}i", var); printf("%i", var);
I do not see an application at that.
|
pawn Код:
// Let's say we have a file that contains
// HouseInt, HousePrice, HouseOutsideX, HouseOutsideY, HouseOutsideZ
// The string looks like this when we get it back; "0|50000|23.0000|123.0000|1.0000"
// We can use the quiet function of sscanf to only get what we currently want (for whatever reason)
new Float:X,Float:Y,Float:Z;
sscanf(file_string, "p<|>{i}{i}fff", X,Y,Z);
// Now our X Y Z variables will be set to the proper values.
// Let's say we wanted to load the pickups or CPs for entering the house
// in a different function than where we set the textlabels data.
// That would be one use of this function
It's good if you want to load separate things at separate times even though they're contained in the same file.
Respuesta: Re: What use is "quiet"? - sscanf -
GranaT3 - 01.11.2015
Quote:
Originally Posted by Kevln
It ignores the first integer in the string.
var = -100
|
Yes, but the question is what use?
Respuesta: Re: What use is "quiet"? - sscanf -
GranaT3 - 02.11.2015
Quote:
Originally Posted by [ABK]Antonio
pawn Код:
// Let's say we have a file that contains // HouseInt, HousePrice, HouseOutsideX, HouseOutsideY, HouseOutsideZ
// The string looks like this when we get it back; "0|50000|23.0000|123.0000|1.0000"
// We can use the quiet function of sscanf to only get what we currently want (for whatever reason) new Float:X,Float:Y,Float:Z; sscanf(file_string, "p<|>{i}{i}fff", X,Y,Z);
// Now our X Y Z variables will be set to the proper values. // Let's say we wanted to load the pickups or CPs for entering the house // in a different function than where we set the textlabels data. // That would be one use of this function
It's good if you want to load separate things at separate times even though they're contained in the same file.
|
This would not be the same as my code ?:
pawn Код:
new var,var2;
sscanf("20 30 50", "ii", var,var2);
printf("%i %i", var,var2);
Re: What use is "quiet"? - sscanf -
Jefff - 02.11.2015
No, same is
pawn Код:
new var,var2;
sscanf("20 30 50", "{i}ii", var,var2);
printf("%i %i", var,var2);
we don't need 20 as he 0|50000
Respuesta: Re: What use is "quiet"? - sscanf -
GranaT3 - 02.11.2015
Quote:
Originally Posted by Jefff
No, same is
pawn Код:
new var,var2; sscanf("20 30 50", "{i}ii", var,var2); printf("%i %i", var,var2);
we don't need 20 as he 0|50000
|
That preserves the value 20?.
My code if you change the value to 0?, i think i understand.
Re: What use is "quiet"? - sscanf -
Kevln - 02.11.2015
pawn Код:
new var,var2;
sscanf("20 30 50", "{i}ii", var,var2);
printf("%i %i", var,var2);
Ignore first integer, process the rest.
var = 30
var2 = 50
Respuesta: Re: What use is "quiet"? - sscanf -
GranaT3 - 02.11.2015
Quote:
Originally Posted by Kevln
pawn Код:
new var,var2; sscanf("20 30 50", "{i}ii", var,var2); printf("%i %i", var,var2);
Ignore first integer, process the rest.
var = 30
var2 = 50
|
Yes. What I want to know if your code works like mine ?:
pawn Код:
new var,var2;
sscanf("20 30 50", "ii", var,var2);
printf("%i %i", var,var2);
var = 20 = processes it
var2 = 30 = processes it
50 = ??: I want to know what happens with the value "50" that I'm not using with quiet