Problems with loading achievements
#1

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

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

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

we need se the SAVING SYSTEM for correct load system dude
Reply
#5

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

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

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

In that case, sscanf also supports arrays.
Reply
#9

So, what would actually the code be?
Reply
#10

What is the size of Ach and AchCompleted?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)