Saving and loading [DINI]
#1

Alright, I'm working on a Clothing system, it saves perfectly but it doesn't load (it leaves the numbers empty after I restart the server, the saving works I checked when I bought the cloth it saved everything) Here are the codes:

OnPlayerLogin

pawn Код:
for(new i = 1; i < 11; i++)
                {
                    new var[32];
                    format(var, sizeof(var), "clothBone%d", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothBone][i] = strvalEx( val ); }
                    format(var, sizeof(var), "clothSlot%d", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot][i] = strvalEx( val ); }
                    format(var, sizeof(var), "clothSlot%d_X", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_X][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_Y", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_Y][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_Z", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_Z][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_RX", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_RX][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_RY", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_RY][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_RZ", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_RZ][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_SX", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_SX][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_SY", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_SY][i] = floatstr(val); }
                    format(var, sizeof(var), "clothSlot%d_SZ", i);
                    if(strcmp(key , var , true) == 0) { val = ini_GetValue( Data ); ClothingInfo[playerid][clothSlot_SZ][i] = floatstr(val); }

                }
                // Had'ol o5ra t7teha
                if( strcmp( key , "clothingName1" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][1], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName2" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][2], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName3" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][3], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName4" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][4], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName5" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][5], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName6" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][6], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName7" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][7], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName8" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][8], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName9" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][9], clothingname, 0, strlen(clothingname), 255); }
                if( strcmp( key , "clothingName10" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(ClothingName[playerid][10], clothingname, 0, strlen(clothingname), 255); }

OnPlayerSave

pawn Код:
for (new i = 1; i < 11; i++)
                {
                    format(var, 32, "clothBone%d=%f\n",i,ClothingInfo[playerid][clothBone][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d=%d\n",i,ClothingInfo[playerid][clothSlot][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_X=%f\n",i,ClothingInfo[playerid][clothSlot_X][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_Y=%f\n",i,ClothingInfo[playerid][clothSlot_Y][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_Z=%f\n",i,ClothingInfo[playerid][clothSlot_Z][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_RX=%f\n",i,ClothingInfo[playerid][clothSlot_RX][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_RY=%f\n",i,ClothingInfo[playerid][clothSlot_RY][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_RZ=%f\n",i,ClothingInfo[playerid][clothSlot_RZ][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_SX=%f\n",i,ClothingInfo[playerid][clothSlot_SX][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_SY=%f\n",i,ClothingInfo[playerid][clothSlot_SY][i]);fwrite(hFile, var);
                    format(var, 32, "clothSlot%d_SZ=%f\n",i,ClothingInfo[playerid][clothSlot_SZ][i]);fwrite(hFile, var);
                    format(var, 32, "clothingName%d=%s\n",i,ClothingName[playerid][i]);fwrite(hFile, var);

                }

Thanks in advance, As I said the problem isnt in saving its in loading it deletes the things again
Reply
#2

Any help buddies!?
Reply
#3

Hmm, don't try to restart server, try to log off, and log back ON. Trust me, I know what I'm saying. If the results will be positive, then your code is OKAY, in order for data to save when there's a server restart you need a DataBase system like MySQL, not a UserFile(like DINI is :P) system as far as I am concerned.
Reply
#4

I can't use MYSQL any suggestion to make this efficient in restarting!?

I tried to buy and quit from the server and log-in again, there are no clothing, then the format is wrong any help!?

It saves but when I tried to log-in it deletes

OnPlayerLogin [MYSQL]

pawn Код:
new var[32];
                for (new i = 1; i < 11; i++)
                {
                    format(var, sizeof(var), "clothBone%d", i);
                    ClothingInfo[playerid][clothBone][i] = MySQL_GetAccountInt(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d", i);
                    ClothingInfo[playerid][clothSlot][i] = MySQL_GetAccountInt(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_X", i);
                    ClothingInfo[playerid][clothSlot_X][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_Y", i);
                    ClothingInfo[playerid][clothSlot_Y][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_Z", i);
                    ClothingInfo[playerid][clothSlot_Z][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_RX", i);
                    ClothingInfo[playerid][clothSlot_RX][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_RY", i);
                    ClothingInfo[playerid][clothSlot_RY][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_RZ", i);
                    ClothingInfo[playerid][clothSlot_RZ][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_SX", i);
                    ClothingInfo[playerid][clothSlot_SX][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_SY", i);
                    ClothingInfo[playerid][clothSlot_SY][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);

                    format(var, sizeof(var), "clothSlot%d_SZ", i);
                    ClothingInfo[playerid][clothSlot_SZ][i] = MySQL_GetAccountFloat(PlayerName(playerid), var);
                }
                MySQL_GetAccountField(PlayerName(playerid), "clothingName1", clothingname); strmid(ClothingName[playerid][1], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName2", clothingname); strmid(ClothingName[playerid][2], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName3", clothingname); strmid(ClothingName[playerid][3], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName4", clothingname); strmid(ClothingName[playerid][4], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName5", clothingname); strmid(ClothingName[playerid][5], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName6", clothingname); strmid(ClothingName[playerid][6], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName7", clothingname); strmid(ClothingName[playerid][7], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName8", clothingname); strmid(ClothingName[playerid][8], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName9", clothingname); strmid(ClothingName[playerid][9], clothingname, 0, strlen(clothingname), 255);
                MySQL_GetAccountField(PlayerName(playerid), "clothingName10", clothingname); strmid(ClothingName[playerid][10], clothingname, 0, strlen(clothingname), 255);

OnPlayerSave [MYSQL]

pawn Код:
new var[32];
                for (new i = 1; i < 11; i++)
                {
                    format(var, sizeof(var), "`clothBone%d` = '%d', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothBone][i]);

                    format(var, sizeof(var), "`clothSlot%d` = '%d', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot][i]);

                    format(var, sizeof(var), "`clothSlot%d_X` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_X][i]);

                    format(var, sizeof(var), "`clothSlot%d_Y` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_Y][i]);

                    format(var, sizeof(var), "`clothSlot%d_Z` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_Z][i]);

                    format(var, sizeof(var), "`clothSlot%d_RX` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_RX][i]);

                    format(var, sizeof(var), "`clothSlot%d_RY` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_RY][i]);

                    format(var, sizeof(var), "`clothSlot%d_RZ` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_RZ][i]);

                    format(var, sizeof(var), "`clothSlot%d_SX` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_SX][i]);

                    format(var, sizeof(var), "`clothSlot%d_SY` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_SY][i]);

                    format(var, sizeof(var), "`clothSlot%d_SZ` = '%f', ", i);
                    formatcat(query, var, ClothingInfo[playerid][clothSlot_SZ][i]);

                    format(var, sizeof(var), "`clothingName%d` = '%s', ", i);
                    formatcat(query, var, ClothingName[playerid][i]);
                }

Can anyone check that I converted them correctly or something? if not please tell me what's the problem and post the new code, thanks in advance.

MYSQL_GetAccountFloat meant to be this

pawn Код:
stock Float:MySQL_GetAccountFloat(const account[], const fieldname[])
{
    new destination[128];
    MySQL_GetAccountField(account, fieldname, destination);
    return floatstr(destination);
}
formatcat means to be:

pawn Код:
#define formatcat(%1,%2,%3) do { new _str[255]; format(_str, 255, %2, %3); strcat(%1,_str); } while(FALSE)
Reply
#5

Any help!? I just want you guys to convert the MYSQL. BUMP
Reply
#6

I Have Same Problem too I am try use this but still can't saved
Quote:

formatcat(query, "`clothBone1` = '%d', ", ClothingInfo[playerid][clothSlot][1]);
formatcat(query, "`clothSlot1` = '%d', ", ClothingInfo[playerid][clothBone][1]);
formatcat(query, "`clothSlot1_X` = '%f', ", ClothingInfo[playerid][clothSlot_X][1]);
formatcat(query, "`clothSlot1_Y` = '%f', ", ClothingInfo[playerid][clothSlot_Y][1]);
formatcat(query, "`clothSlot1_Z` = '%f', ", ClothingInfo[playerid][clothSlot_Z][1]);
formatcat(query, "`clothSlot1_RX` = '%f', ", ClothingInfo[playerid][clothSlot_RX][1]);
formatcat(query, "`clothSlot1_RY` = '%f', ", ClothingInfo[playerid][clothSlot_RY][1]);
formatcat(query, "`clothSlot1_RZ` = '%f', ", ClothingInfo[playerid][clothSlot_RZ][1]);
formatcat(query, "`clothSlot1_SX` = '%f', ", ClothingInfo[playerid][clothSlot_SX][1]);
formatcat(query, "`clothSlot1_SY` = '%f', ", ClothingInfo[playerid][clothSlot_SY][1]);
formatcat(query, "`clothSlot1_SZ` = '%f', ", ClothingInfo[playerid][clothSlot_SZ][1]);
formatcat(query, "`clothingName1` = '%s', ", ClothingName[playerid][1]);
formatcat(query, "`clothBone2` = '%d', ", ClothingInfo[playerid][clothSlot][2]);
formatcat(query, "`clothSlot2` = '%d', ", ClothingInfo[playerid][clothBone][2]);
formatcat(query, "`clothSlot2_X` = '%f', ", ClothingInfo[playerid][clothSlot_X][2]);
formatcat(query, "`clothSlot2_Y` = '%f', ", ClothingInfo[playerid][clothSlot_Y][2]);
formatcat(query, "`clothSlot2_Z` = '%f', ", ClothingInfo[playerid][clothSlot_Z][2]);
formatcat(query, "`clothSlot2_RX` = '%f', ", ClothingInfo[playerid][clothSlot_RX][2]);
formatcat(query, "`clothSlot2_RY` = '%f', ", ClothingInfo[playerid][clothSlot_RY][2]);
formatcat(query, "`clothSlot2_RZ` = '%f', ", ClothingInfo[playerid][clothSlot_RZ][2]);
formatcat(query, "`clothSlot2_SX` = '%f', ", ClothingInfo[playerid][clothSlot_SX][2]);
formatcat(query, "`clothSlot2_SY` = '%f', ", ClothingInfo[playerid][clothSlot_SY][2]);
formatcat(query, "`clothSlot2_SZ` = '%f', ", ClothingInfo[playerid][clothSlot_SZ][2]);
formatcat(query, "`clothingName2` = '%s', ", ClothingName[playerid][2]);
formatcat(query, "`clothBone3` = '%d', ", ClothingInfo[playerid][clothSlot][3]);
formatcat(query, "`clothSlot3` = '%d', ", ClothingInfo[playerid][clothBone][3]);
formatcat(query, "`clothSlot3_X` = '%f', ", ClothingInfo[playerid][clothSlot_X][3]);
formatcat(query, "`clothSlot3_Y` = '%f', ", ClothingInfo[playerid][clothSlot_Y][3]);
formatcat(query, "`clothSlot3_Z` = '%f', ", ClothingInfo[playerid][clothSlot_Z][3]);
formatcat(query, "`clothSlot3_RX` = '%f', ", ClothingInfo[playerid][clothSlot_RX][3]);
formatcat(query, "`clothSlot3_RY` = '%f', ", ClothingInfo[playerid][clothSlot_RY][3]);
formatcat(query, "`clothSlot3_RZ` = '%f', ", ClothingInfo[playerid][clothSlot_RZ][3]);
formatcat(query, "`clothSlot3_SX` = '%f', ", ClothingInfo[playerid][clothSlot_SX][3]);
formatcat(query, "`clothSlot3_SY` = '%f', ", ClothingInfo[playerid][clothSlot_SY][3]);
formatcat(query, "`clothSlot3_SZ` = '%f', ", ClothingInfo[playerid][clothSlot_SZ][3]);
formatcat(query, "`clothingName3` = '%s', ", ClothingName[playerid][3]);
formatcat(query, "`clothBone4` = '%d', ", ClothingInfo[playerid][clothSlot][4]);
formatcat(query, "`clothSlot4` = '%d', ", ClothingInfo[playerid][clothBone][4]);
formatcat(query, "`clothSlot4_X` = '%f', ", ClothingInfo[playerid][clothSlot_X][4]);
formatcat(query, "`clothSlot4_Y` = '%f', ", ClothingInfo[playerid][clothSlot_Y][4]);
formatcat(query, "`clothSlot4_Z` = '%f', ", ClothingInfo[playerid][clothSlot_Z][4]);
formatcat(query, "`clothSlot4_RX` = '%f', ", ClothingInfo[playerid][clothSlot_RX][4]);
formatcat(query, "`clothSlot4_RY` = '%f', ", ClothingInfo[playerid][clothSlot_RY][4]);
formatcat(query, "`clothSlot4_RZ` = '%f', ", ClothingInfo[playerid][clothSlot_RZ][4]);
formatcat(query, "`clothSlot4_SX` = '%f', ", ClothingInfo[playerid][clothSlot_SX][4]);
formatcat(query, "`clothSlot4_SY` = '%f', ", ClothingInfo[playerid][clothSlot_SY][4]);
formatcat(query, "`clothSlot4_SZ` = '%f', ", ClothingInfo[playerid][clothSlot_SZ][4]);
formatcat(query, "`clothingName4` = '%s', ", ClothingName[playerid][4]);
formatcat(query, "`clothBone5` = '%d', ", ClothingInfo[playerid][clothSlot][5]);
formatcat(query, "`clothSlot5` = '%d', ", ClothingInfo[playerid][clothBone][5]);
formatcat(query, "`clothSlot5_X` = '%f', ", ClothingInfo[playerid][clothSlot_X][5]);
formatcat(query, "`clothSlot5_Y` = '%f', ", ClothingInfo[playerid][clothSlot_Y][5]);
formatcat(query, "`clothSlot5_Z` = '%f', ", ClothingInfo[playerid][clothSlot_Z][5]);
formatcat(query, "`clothSlot5_RX` = '%f', ", ClothingInfo[playerid][clothSlot_RX][5]);
formatcat(query, "`clothSlot5_RY` = '%f', ", ClothingInfo[playerid][clothSlot_RY][5]);
formatcat(query, "`clothSlot5_RZ` = '%f', ", ClothingInfo[playerid][clothSlot_RZ][5]);
formatcat(query, "`clothSlot5_SX` = '%f', ", ClothingInfo[playerid][clothSlot_SX][5]);
formatcat(query, "`clothSlot5_SY` = '%f', ", ClothingInfo[playerid][clothSlot_SY][5]);
formatcat(query, "`clothSlot5_SZ` = '%f', ", ClothingInfo[playerid][clothSlot_SZ][5]);
formatcat(query, "`clothingName5` = '%s', ", ClothingName[playerid][5]);

Reply
#7

I have used Dini for the past 4 years and I've never had troubles with it, it works fine but I guess it is different for each gamemode, e.g. I've never made a big RP gamemode.

Now Stanford, I got attracted by this post due to Dini being mentioned, however I do not see Dini actually being used in any of the scripts. What I've seen being used is fwrite and MySQL so far, try the same procedure with a different INI system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)