09.07.2013, 07:14
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
OnPlayerSave
Thanks in advance, As I said the problem isnt in saving its in loading it deletes the things again
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