27.12.2014, 09:03
Okay so i made a save function that will save every single one vehicle in its own file because i need something
I made a function to load vehicles:
Made a save function:
AutaPath stock
Path
On mode init load:
And on mode exit save:
But it wont save ANYTHING please help me asap
I made a function to load vehicles:
Код:
forward UcitajAuto(vehicleid, name[], value[]); public UcitajAuto(vehicleid, name[], value[]) { INI_Int("FirmaID",Vozila[vehicleid][FirmaID]); INI_Int("Vrsta",Vozila[vehicleid][Vrsta]); INI_Bool("Rentano",Vozila[vehicleid][Rentano]); INI_Int("ID",Vozila[vehicleid][ID]); INI_Bool("IsRent",Vozila[vehicleid][IsRent]); INI_String("RentaoGa",Vozila[vehicleid][RentaoGa],24); INI_Bool("COCar",Vozila[vehicleid][COCar]); INI_Bool("COMotor",Vozila[vehicleid][COMotor]); INI_Bool("COLetjelica",Vozila[vehicleid][COLetjelica]); INI_Bool("COPlovilo",Vozila[vehicleid][COPlovilo]); INI_String("Vlasnik",Vozila[vehicleid][Vlasnik],24); INI_Bool("Locked",Vozila[vehicleid][Locked]); INI_Bool("HouseCar",Vozila[vehicleid][HouseCar]); INI_String("HCVlasnik",Vozila[vehicleid][HCVlasnik],24); INI_Int("Radio",Vozila[vehicleid][Radio]); INI_Int("Kilometraza",Vozila[vehicleid][Kilometraza]); return 1; }
Код:
stock SacuvajAuta(vehicleid) { new INI:File = INI_Open(AutaPath(vehicleid)); INI_SetTag(File,"data"); INI_WriteInt(File,"FirmaID",Vozila[vehicleid][FirmaID]); INI_WriteInt(File,"Vrsta",Vozila[vehicleid][Vrsta]); INI_WriteBool(File,"Rentano",Vozila[vehicleid][Rentano]); INI_WriteInt(File,"ID",Vozila[vehicleid][ID]); INI_WriteBool(File,"IsRent",Vozila[vehicleid][IsRent]); INI_WriteString(File,"RentaoGa",Vozila[vehicleid][RentaoGa]); INI_WriteBool(File,"COCar",Vozila[vehicleid][COCar]); INI_WriteBool(File,"COMotor",Vozila[vehicleid][COMotor]); INI_WriteBool(File,"COLetjelica",Vozila[vehicleid][COLetjelica]); INI_WriteBool(File,"COPlovilo",Vozila[vehicleid][COPlovilo]); INI_WriteString(File,"Vlasnik",Vozila[vehicleid][Vlasnik]); INI_WriteBool(File,"Locked",Vozila[vehicleid][Locked]); INI_WriteBool(File,"HouseCar",Vozila[vehicleid][HouseCar]); INI_WriteString(File,"HCVlasnik",Vozila[vehicleid][HCVlasnik]); INI_WriteInt(File,"Radio",Vozila[vehicleid][Radio]); INI_WriteInt(File,"Kilometraza",Vozila[vehicleid][Kilometraza]); INI_Close(File); return 1; }
Код:
stock AutaPath(vehicleid) { new string[128]; format(string,sizeof(string),AUTA_FILE,vehicleid); return string; }
Код:
#define AUTA_FILE "Auta/%d.ini"
Код:
for(new vehicleid = 0; vehicleid < sizeof(Vozila); vehicleid++) { new vFile[50]; format(vFile, sizeof(vFile), AUTA_FILE, vehicleid); if(fexist(vFile)) { INI_ParseFile(vFile, "UcitajAuto", .bExtra = true, .extra = vehicleid); } else { SacuvajAuta(vehicleid); } }
Код:
for(new vehicleid = 0; vehicleid < sizeof(Vozila); vehicleid++) { SacuvajAuta(vehicleid); }