SA-MP Forums Archive
Problems with loading achievements - 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: Problems with loading achievements (/showthread.php?tid=537401)



Problems with loading achievements - biker122 - 15.09.2014

So, I've been working on an achievements system; The problem is the achievements are not being saved into the variables.. BUT THEY DO RETRIEVE THEM. I can see the variables on the mysql log. I even tried printing the the variables on the console, but all of them shown 0.

pawn Код:
stock LoadPlayerAchievements(playerid)
{
    new TQuery[600], shotitname[24], shotid;
    format(TQuery, 600, "SELECT * FROM `"Achievements"` WHERE `Username` = '%s'", GetPName(playerid));
    mysql_query(TQuery), mysql_store_result();
    mysql_fetch_row_format(TQuery);
    for(new i = 0; i <= 15; i++)
    {
        sscanf(TQuery, "e<p<|>is[24]iiiiiiiiiiiiiiii>", shotid, shotitname, PInfo[playerid][Ach][i], PInfo[playerid][AchsCompleted]);
    }
    mysql_free_result(), printf("%s's completed var is %i", GetPName(playerid), PInfo[playerid][AchsCompleted]);
    return 1;
}



Re: Problems with loading achievements - Eth - 15.09.2014

if so you have to show us the SAVING not the LOADING function


Re: Problems with loading achievements - biker122 - 15.09.2014

The saving process is doing it's job well, and they're correctly stored into the database.
They're not being stored in the variable after retrieving it from the database.


Re: Problems with loading achievements - Toxik - 15.09.2014

we need se the SAVING SYSTEM for correct load system dude


Re: Problems with loading achievements - biker122 - 15.09.2014

This is how I save the achievements in the database:

pawn Код:
stock SavePlayerAchievements(playerid)
{
    new TQuery[600];
    if(PInfo[playerid][AchsCompleted] != 0)
    {
        format(TQuery, 600, "UPDATE `"Achievements"` SET `Ach1` = '%i', `Ach2` = '%i', `Ach3` = '%i', `Ach4` = '%i', `Ach5` = '%i', `Ach6` = '%i', `Ach7` = '%i', `Ach8` = '%i', `Ach9` = '%i', `Ach10` = '%i', `Ach11` = '%i', `Ach12` = '%i', `Ach13` = '%i', `Ach14` = '%i', `Ach15` = '%i', `AchsCompleted` = '%i' WHERE `Username` = '%s'",
                    PInfo[playerid][Ach][0], PInfo[playerid][Ach][1], PInfo[playerid][Ach][2], PInfo[playerid][Ach][3], PInfo[playerid][Ach][4], PInfo[playerid][Ach][5], PInfo[playerid][Ach][6], PInfo[playerid][Ach][7], PInfo[playerid][Ach][8], PInfo[playerid][Ach][9],
                    PInfo[playerid][Ach][10], PInfo[playerid][Ach][11], PInfo[playerid][Ach][12], PInfo[playerid][Ach][13], PInfo[playerid][Ach][14], PInfo[playerid][AchsCompleted], GetPName(playerid));
    }
    mysql_query(TQuery);
    return 1;
}



Re: Problems with loading achievements - dusk - 15.09.2014

pawn Код:
mysql_query(TQuery), mysql_store_result();
    mysql_fetch_row_format(TQuery);
    for(new i = 0; i <= 15; i++)
    {
        sscanf(TQuery, "e<p<|>is[24]iiiiiiiiiiiiiiii>", shotid, shotitname, PInfo[playerid][Ach][i], PInfo[playerid][AchsCompleted]);
    }
Why do you load the same data 16 times?

pawn Код:
mysql_query(TQuery);
mysql_store_result();
while(mysql_fetch_row_format(TQuery))
{
    sscanf(TQuery, "e<p<|>is[24]iiiiiiiiiiiiiiii>", shotid, shotitname, PInfo[playerid][Ach][i], PInfo[playerid][AchsCompleted]);
}
This is somethin, but there are still more specifiers than variables.


Re: Problems with loading achievements - biker122 - 15.09.2014

No.
shotid - Auto increment value
shotitname - Username on database
PInfo[playerid][Ach][16] | 15 specifiers - 15 achievements
1 specifier - Completed achs no.


Re: Problems with loading achievements - dusk - 15.09.2014

In that case, sscanf also supports arrays.


Re: Problems with loading achievements - biker122 - 15.09.2014

So, what would actually the code be?


Re: Problems with loading achievements - dusk - 15.09.2014

What is the size of Ach and AchCompleted?