13.06.2014, 23:50
Hello, I have a problem with the saved data of garages.
No error in the code, but to close the server and open the (garage.cfg) is again at 0 and garages are removed.
Please, help :/
CODE LOAD:
CODE SAVE:
In OnGameModeInit I placed the following conditions:
No error in the code, but to close the server and open the (garage.cfg) is again at 0 and garages are removed.
Please, help :/
CODE LOAD:
Code:
stock LoadGarages() { new binfo[21][32]; new string[256]; new File:file = fopen("garages.cfg", io_read); if(file) { new idx = 1; while(idx < MAX_GARAGES) { fread(file, string); split(string, binfo, '|'); format(GarageInfo[idx][gOwner], 32, "%s", binfo[3]); GarageInfo[idx][gX] = floatstr(binfo[4]); GarageInfo[idx][gY] = floatstr(binfo[5]); GarageInfo[idx][gZ] = floatstr(binfo[6]); if(GarageInfo[idx][gLevel]) { GarageInfo[idx][gPickup] = CreateDynamicPickup(1318, 1, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ], 0); if(!strcmp("Gobierno", GarageInfo[idx][gOwner])) format(string, sizeof(string), ""COL_WHITE"["COL_WHITE"%d, Garage (Lvl: %d)\n"COL_WHITE"\n"COL_WHITE"Dueсo"COL_WHITE" %s\n"COL_WHITE"$%d", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner], GarageInfo[idx][gPrice]); else format(string, sizeof(string), ""COL_WHITE"["COL_WHITE"%d, Garage (Nivel: %d)"COL_WHITE"]\n"COL_WHITE"Dueсo"COL_WHITE" %s", idx, GarageInfo[idx][gLevel], GarageInfo[idx][gOwner]); GarageInfo[idx][gText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ]+0.3, 15); } idx++; } } print("Garages Cargados Correctamente."); return 1; }
Code:
stock SaveGarages() { new idx = 1, File:file; new string[256]; while(idx < MAX_GARAGES) { format(string, sizeof(string), "%d|%d|%s|%f|%f|%f\r\n", GarageInfo[idx][gLevel], GarageInfo[idx][gPrice], GarageInfo[idx][gOwner], GarageInfo[idx][gX], GarageInfo[idx][gY], GarageInfo[idx][gZ] ); if(idx == 1) { file = fopen("garages.cfg", io_write); } else { file = fopen("garages.cfg", io_append); } fwrite(file, string); fclose(file); idx++; } print("Garages Guardados Correctamente."); }
In OnGameModeInit I placed the following conditions:
Code:
SaveGarages();//Garages LoadGarages();//Garages