Convert This Code
#1

i Convert this code from YNI but this not work help me fix this
Код HTML:
stock SaveEVO()
{
    new FileName[128];
    format(FileName, sizeof(FileName), "EVO/options.ini");
    if(dini_Exists(FileName))
    {
	    dini_IntSet(FileName, "LASTVEHICLEID", LastEvoVehicleID);
	    dini_IntSet(FileName, "LASTSHOWROOMID", LastShowroomID);
    }
}
Код HTML:
public CreateEvoVehicle(Modelid, Owner[], Float:X, Float:Y, Float:Z, Float:Rot, Col1, Col2, Price)
{
	new CreatedID;
	new FileName[128];
	CreatedID = GetEmptyEvoVehicleID();
	Iter_Add(EVs, CreatedID);
	LastEvoVehicleID = Iter_Last(EVs)+1;
	EvoVehicles[CreatedID][EVModel] = Modelid;
	format(EvoVehicles[CreatedID][EVOwner], 40, Owner);
	EvoVehicles[CreatedID][EVX] = X;
	EvoVehicles[CreatedID][EVY] = Y;
	EvoVehicles[CreatedID][EVZ] = Z;
	EvoVehicles[CreatedID][EVRot] = Rot;
	EvoVehicles[CreatedID][EVCol1] = Col1;
	EvoVehicles[CreatedID][EVCol2] = Col2;
	EvoVehicles[CreatedID][EVPrice] = Price;
	EvoVehicles[CreatedID][EVSecurity] = 0;
	EvoVehicles[CreatedID][EVLock] = 0;
	format(EvoVehicles[CreatedID][EVPlate], 30, Owner);
	EvoVehicles[CreatedID][EVPJ] = -1;
	EvoVehicles[CreatedID][EVExist] = 1;
	EvoVehicles[CreatedID][EVVehID] = CreateVehicle(Modelid, X, Y, Z, Rot, Col1, Col2, -1);
	VehEVID[ EvoVehicles[CreatedID][EVVehID] ] = CreatedID;
	VehInSystem[ EvoVehicles[CreatedID][EVVehID] ] = 1;
	SetVehicleNumberPlate(EvoVehicles[CreatedID][EVVehID], Owner);
	SetVehicleToRespawn(EvoVehicles[CreatedID][EVVehID]);
	format(FileName, 35, "EVO/Vehicle_%d.ini", CreatedID);
	dini_Create(FileName);
	dini_IntSet(FileName, "MODEL", Modelid);
	dini_FloatSet(FileName, "X", X);
	dini_FloatSet(FileName, "Y", Y);
	dini_FloatSet(FileName, "Z", Z);
	dini_FloatSet(FileName, "ROT", Rot);
	dini_IntSet(FileName, "COL1", Col1);
	dini_IntSet(FileName, "COL2", Col2);
	dini_IntSet(FileName, "PRICE", Price);
	dini_IntSet(FileName, "SECURITY", 0);
	dini_IntSet(FileName, "LOCK", 0);
	return CreatedID;
}
Код HTML:
public LoadEvoVehicle_evo(EvoVehicleID, name[], value[])
{
    new FileName[128];
	dini_IntSet(FileName,"MODEL", EvoVehicles[ EvoVehicleID ][EVModel]);
	dini_FloatSet(FileName,"X", EvoVehicles[ EvoVehicleID ][EVX]);
	dini_FloatSet(FileName,"Y", EvoVehicles[ EvoVehicleID ][EVY]);
	dini_FloatSet(FileName,"Z", EvoVehicles[ EvoVehicleID ][EVZ]);
	dini_FloatSet(FileName,"ROT", EvoVehicles[ EvoVehicleID ][EVRot]);
	dini_IntSet(FileName,"COL1", EvoVehicles[ EvoVehicleID ][EVCol1]);
	dini_IntSet(FileName,"COL2", EvoVehicles[ EvoVehicleID ][EVCol2]);
	dini_IntSet(FileName,"PRICE", EvoVehicles[ EvoVehicleID ][EVPrice]);
	dini_IntSet(FileName,"SECURITY", EvoVehicles[ EvoVehicleID ][EVSecurity]);
	dini_IntSet(FileName,"LOCK", EvoVehicles[ EvoVehicleID ][EVLock]);
	EvoVehicles[EvoVehicleID][EVExist] = 1;
	return 1;
}
Код HTML:
public SaveEvoVehicles(last)
{
	new FileName[128], SavedCount;
	Unloading = last;
	new Float:NewX, Float:NewY, Float:NewZ, Float:NewRot;
	for(new i = LastSaved; i < LastEvoVehicleID; i++)
	{
		if(EvoVehicles[i][EVExist] == 1)
		{
		    #if AUTOMATIC_PARK == true

			GetVehiclePos(EvoVehicles[i][EVVehID], NewX, NewY, NewZ);
			GetVehicleZAngle(EvoVehicles[i][EVVehID], NewRot);

			if(NewX != EvoVehicles[i][EVX] || NewY != EvoVehicles[i][EVY] || NewZ != EvoVehicles[i][EVZ] || NewRot != EvoVehicles[i][EVRot]) EvoVehicles[i][EVNeedSave] = 1;

			#else

			GetVehiclePos(EvoVehicles[i][EVVehID], NewX, NewY, NewZ);
			GetVehicleZAngle(EvoVehicles[i][EVVehID], NewRot);

			if((!strcmp("-", EvoVehicles[i][EVOwner], true) || !strfind(EvoVehicles[i][EVOwner], "Galeri", true)) ) && ( NewX != EvoVehicles[i][EVX] || NewY != EvoVehicles[i][EVY] || NewZ != EvoVehicles[i][EVZ] || NewRot != EvoVehicles[i][EVRot] )) EvoVehicles[i][EVNeedSave] = 1;

			#endif

			if(EvoVehicles[i][EVNeedSave] == 1)
		    {
		        if(SavedCount == 10 && Unloading == 0)
		        {
		            LastSaved = i;
		            SetTimer("SaveEvoVehicles", 5000, 0);
		            break;
		        }
		    	format(FileName, 35, "%s/Vehicle_%d.ini", EVOVEHICLE_VEHICLE_DIR, i);
				dini_IntSet(FileName, "MODEL", EvoVehicles[i][EVModel]);
				dini_FloatSet(FileName, "X", EvoVehicles[i][EVX]);
				dini_FloatSet(FileName, "Y", EvoVehicles[i][EVY]);
				dini_FloatSet(FileName, "Z", EvoVehicles[i][EVZ]);
				dini_FloatSet(FileName, "ROT", EvoVehicles[i][EVRot]);
				dini_IntSet(FileName, "COL1", EvoVehicles[i][EVCol1]);
				dini_IntSet(FileName, "COL2", EvoVehicles[i][EVCol2]);
				dini_IntSet(FileName, "PRICE", EvoVehicles[i][EVPrice]);
				dini_IntSet(FileName, "SECURITY", EvoVehicles[i][EVSecurity]);
				dini_IntSet(FileName, "LOCK", EvoVehicles[i][EVLock]);
				SavedCount++;
		    }
		}

		if(i == LastEvoVehicleID-1)
		{
		    LastSaved = 0;
		    break;
		}
	}
}
Код HTML:
public CreateShowroom(Name[], Float:X, Float:Y, Float:Z)
{
	new CreatedID = GetEmptyShowroomID();

	Iter_Add(SRs, CreatedID);
	LastShowroomID = Iter_Last(SRs)+1;

	format(Showrooms[CreatedID][SRName], 100, Name);
	Showrooms[CreatedID][SRX] = X;
	Showrooms[CreatedID][SRY] = Y;
	Showrooms[CreatedID][SRZ] = Z;
	Showrooms[CreatedID][SRExist] = 1;

	Showrooms[CreatedID][SRPick] = CreatePickup(1239, 1, X, Y, Z, 0);

	new String[128];
	format(String, 128, "{ADFF2F}SHOWROOM\n{ADFF2F}%s\n{FFFFFF}Showroom ID {ADFF2F}%d", Showrooms[CreatedID][SRName], CreatedID);
	Showrooms[CreatedID][SR3D] = Create3DTextLabel(String, -1, X, Y, Z, 25.0, 0);

	new FileName[35];
	format(FileName, 35, "%s/Showroom_%d.ini", EVOVEHICLE_SHOWROOM_DIR, CreatedID);
	dini_Int(FileName, "NAME");
	dini_FloatSet(FileName, "X", X);
	dini_FloatSet(FileName, "Y", Y);
	dini_FloatSet(FileName, "Z", Z);
	return CreatedID;
}
Код HTML:
public LoadShowroom_evo(ShowroomID, name[], value[])
{
    new FileName[128];
	dini_IntSet(FileName, "NAME", Showrooms[ ShowroomID ][SRName]);
	dini_FloatSet(FileName, "X", Showrooms[ ShowroomID ][SRX]);
	dini_FloatSet(FileName, "Y", Showrooms[ ShowroomID ][SRY]);
	dini_FloatSet(FileName, "Z", Showrooms[ ShowroomID ][SRZ]);
	Showrooms[ ShowroomID ][SRExist] = 1;
	return 1;
}

// - Save Showrooms
public SaveShowrooms(last)
{
	new FileName[128], SavedCount;
	Unloading = last;

	for(new i = LastSavedSR; i < LastShowroomID; i++)
	{
		if(Showrooms[i][SRExist] == 1)
		{
			if(Showrooms[i][SRNeedSave] == 1)
		    {
		        if(SavedCount == 10 && Unloading == 0)
		        {
		            LastSavedSR = i;
		            SetTimer("SaveShowrooms", 5000, 0);
		            break;
		        }
		    	format(FileName, 35, "%s/Showroom_%d.ini", EVOVEHICLE_SHOWROOM_DIR, i);
				dini_IntSet(FileName, "NAME", Showrooms[i][SRName]);
				dini_FloatSet(FileName, "X", Showrooms[i][SRX]);
				dini_FloatSet(FileName, "Y", Showrooms[i][SRY]);
				dini_FloatSet(FileName, "Z", Showrooms[i][SRZ]);
				SavedCount++;
		    }
		}

		if(i == LastShowroomID-1)
		{
		    LastSavedSR = 0;
		    break;
		}
	}
}
Reply
#2

buzz
Reply
#3

this code not save and load file
Reply
#4

bump
Reply
#5

help me please
Reply
#6

Are you a bot or what? bumping and bumping around.

Man it is possible to convert but is not easy to do. I hope you understand that no one will fix this case unless there kind hearted people will help you.
Reply
#7

It'll take time to convert your code but I'll give you a hint, I see you haven't used dini_int/dini_float at all on that script, And you should use those for loading..Not dini_intset or dini_floatset
Reply
#8

thanks you +rep Vip3R and inbanner
Reply
#9

and you can help me Convert this fs https://sampforum.blast.hk/showthread.php?tid=449457
because my server can't user owership car T_T
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)