SA-MP Forums Archive
sscanf saving issue - 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: sscanf saving issue (/showthread.php?tid=568378)



sscanf saving issue - Sascha - 21.03.2015

Hi,
I'm facing a problem when loading data from a mysql db...
I'm trying to save them in an enum, here's the code
pawn Код:
stock Load()
{
    new string[100], tmp[300], rows = 0, n = 1;
    format(string, sizeof(string), "SELECT * FROM `table` ORDER BY `id` ASC");
    mysql_query(string);
    mysql_store_result();
    while(mysql_fetch_row(tmp, "|"))
    {
        rows++;
        print(tmp);
        if(!sscanf(tmp, "p<|>e<is[50]iiii>", MyData[n]))
        {
            n++;
        }
    }
    mysql_free_result();
        Count = n;
    return 1;
}
the enum:
pawn Код:
enum CI
{
    compID,
    compName[55],
    compOwner,
    compKind,
    compBank,
    compActive
}
new MyData[][CI];
here's the string that is printed as "tmp" (only 1 line, as there only is one line in the db)
Код:
1|This Name|1|1|0|1
although the data are saved wrong, if I use this:
pawn Код:
for(new n=1; n<=Count; n++)
    {

        format(string, sizeof(string), "%d", MyData[n][compOwner]);
        SendClientMessage(playerid, COLOR_GREY, string);
        format(string, sizeof(string), "%s", MyData[n][compName]);
SendClientMessage(playerid, COLOR_GREY, string);
    }
it shows 0 as owner whereas it should be 1 and nothing for the name.

where's the mistake on that?


AW: sscanf saving issue - Sascha - 22.03.2015

anyone?


AW: sscanf saving issue - Sascha - 25.03.2015

bump


Re: sscanf saving issue - Sascha - 31.03.2015

another bump again


Re: sscanf saving issue - TakeiT - 31.03.2015

I'm going to suggest upgrading your mysql to use threaded queries. It's much easier and less prone to making problems like this, as well as lag-free