What use is "quiet"? - sscanf
#1

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.
Reply
#2

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;
}
Reply
#3

It ignores the first integer in the string.

var = -100
Reply
#4

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.
Reply
#5

Quote:
Originally Posted by Kevln
Посмотреть сообщение
It ignores the first integer in the string.

var = -100
Yes, but the question is what use?
Reply
#6

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);
Reply
#7

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
Reply
#8

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.
Reply
#9

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
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)