Wont save in Y_ini
#1

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:

Код:
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;
}
Made a save function:

Код:
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;
}
AutaPath stock

Код:
stock AutaPath(vehicleid)
{
	new string[128];
	format(string,sizeof(string),AUTA_FILE,vehicleid);
	return string;
}
Path
Код:
#define AUTA_FILE           "Auta/%d.ini"
On mode init load:

Код:
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);
        }
	}
And on mode exit save:

Код:
for(new vehicleid = 0; vehicleid < sizeof(Vozila); vehicleid++)
    {
            SacuvajAuta(vehicleid);
	}
But it wont save ANYTHING please help me asap
Reply
#2

-Edit-
I didn't see the line, let me look further into the problem.

EDIT2: Instead of using the stock function to save your vehicles, try using a public function.
Reply
#3

Quote:
Originally Posted by Bible
Посмотреть сообщение
-Edit-
I didn't see the line, let me look further into the problem.

EDIT2: Instead of using the stock function to save your vehicles, try using a public function.
Whats the difference xD?
Btw i found the problem it didnt save because the loop ongamemode exit was kinda big and it didnt execute so i did the savevehicle onayerexitvehicle callback
Any idea what can i add so the server every now and then saves all vehicles 2k + files without the lagg?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)