SA-MP Forums Archive
SSCANF storing weird numbers? - 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: SSCANF storing weird numbers? (/showthread.php?tid=171533)



SSCANF storing weird numbers? - DiddyBop - 26.08.2010

Well SSCANF enum is returning weirdd numbers, but in the mysql_log its retrieving the info correctly.

pawn Код:
enum pInfos
{
      Info1, // ID
      Info2[24], //username
      Info3[50], //PW
      Info4,
      Info5,
      Info6,
      Info7,
      Info8,
      Info9,
      Info10,
      Info11,
      Info12[30],
      Info13,
      Info14,
      Info15,
      Info16[128]
};
new store[pInfos];

//sscanf line
new row[500];
sscanf(row, "p<|>e<ds[100]s[100]ddddddds[100]dds[100]ds[100]>", store[Info1],store[Info2],store[Info3],store[Info4],store[Info5],store[Info6],store[Info7],store[Info8],store[Info9],store[Info10],store[Info11],store[Info12],store[Info13],store[Info14],store[Info15],store[Info16]);

I had it print the values, and it was like.. 78,79, 80, then up.. Going in order like that.


Re: SSCANF storing weird numbers? - [L3th4l] - 26.08.2010

Check this example:

pawn Код:
enum
    E_DATA
{
    E_DATE_C,
    Float:E_DATA_X,
    E_DATA_NAME[32],
    E_DATA_Z
}

main
{
    new
        var[E_DATA];
    sscanf("1 12.0 Bob c", "e<ifs[32]c>", var);
}



Re: SSCANF storing weird numbers? - bigcomfycouch - 26.08.2010

use the correct string size instead of 100?


Re: SSCANF storing weird numbers? - DiddyBop - 26.08.2010

Quote:
Originally Posted by [L3th4l]
Посмотреть сообщение
Check this example:

pawn Код:
enum
    E_DATA
{
    E_DATE_C,
    Float:E_DATA_X,
    E_DATA_NAME[32],
    E_DATA_Z
}

main
{
    new
        var[E_DATA];
    sscanf("1 12.0 Bob c", "e<ifs[32]c>", var);
}
ok.. changed it to just store, at end of the sscanf input.

Now its just returning 0 on everything


Re: SSCANF storing weird numbers? - DRIFT_HUNTER - 27.08.2010

1.Witch one sscanf?

1)1.0 That you have in script
2)or 2.0 that is the plugin


Re: SSCANF storing weird numbers? - DiddyBop - 27.08.2010

2.0.. the plugin


Re: SSCANF storing weird numbers? - Kyosaur - 27.08.2010

Код:
sscanf(row, "e<p<|>ds[100]s[100]ddddddds[100]dds[100]ds[100]>", store);
Try that


edit: Also, try putting it in an if statement to help with error checking. Something like:

Код:
if(sscanf(row, "e<p<|>ds[100]s[100]ddddddds[100]dds[100]ds[100]>", store))
{
    // Cant parse data 
}
else
{
    //All is well
}
edit2: Chnage the string sizes in sscanf as someone previously said. You can not have them higher than the original array's length; this will cause a nasty buffer overflow.


Re: SSCANF storing weird numbers? - DiddyBop - 27.08.2010

everything still returning 0 Kyo


Re: SSCANF storing weird numbers? - DiddyBop - 27.08.2010

ok i put in an if statement, i put print("i cant bla bla"); under first brackets, and put the rest of the good script, under the else statement.

And its not going to else, is stopping at // cant parse data


Re: SSCANF storing weird numbers? - Kyosaur - 27.08.2010

Quote:
Originally Posted by DiddyBop
Посмотреть сообщение
ok i put in an if statement, i put print("i cant bla bla"); under first brackets, and put the rest of the good script, under the else statement.

And its not going to else, is stopping at // cant parse data
Ok here's the fixed version:

Код:
sscanf(row,"e<p<|>ds[24]s[50]dddddddds[30]ddds[128]>",store)
shove it in your if statement and test. If it doesn't work, i need you to print out "row" for us (one guess would be that your not using a delimiter in row at all (well, i mean you're using space not | :P)).