[Help]Problem
#1

I use this for save cars, and works !

Код:
public SaveDynamicCars()
{
	new idx = 1;
	while (idx < sizeof(DynamicCars))
	{

		new SaveCars[256];
  		format(SaveCars,sizeof(SaveCars),"Sistema/Cars/All/%d.ini",idx);
   		if(!dini_Exists(SaveCars))
	    {
		dini_Create(SaveCars);
		}

  		dini_IntSet(SaveCars,"CarModel", DynamicCars[idx][CarModel]);
  		dini_FloatSet(SaveCars,"CarX", DynamicCars[idx][CarX]);
		dini_FloatSet(SaveCars,"CarY", DynamicCars[idx][CarY]);
		dini_FloatSet(SaveCars,"CarZ", DynamicCars[idx][CarZ]);
		dini_FloatSet(SaveCars,"CarAngle", DynamicCars[idx][CarAngle]);
		dini_IntSet(SaveCars,"CarColor1", DynamicCars[idx][CarColor1]);
		dini_IntSet(SaveCars,"CarColor2", DynamicCars[idx][CarColor2]);
		dini_IntSet(SaveCars,"FactionCar", DynamicCars[idx][FactionCar]);
		dini_IntSet(SaveCars,"CarType", DynamicCars[idx][CarType]);
		dini_IntSet(SaveCars,"cOwner", DynamicCars[idx][cOwner]);
		dini_IntSet(SaveCars,"cDescription", DynamicCars[idx][cDescription]);
		dini_IntSet(SaveCars,"cValue", DynamicCars[idx][cValue]);
		dini_IntSet(SaveCars,"cOwned", DynamicCars[idx][cOwned]);
		dini_IntSet(SaveCars,"cLock", DynamicCars[idx][cLock]);
		idx++;
	}
	return 1;
}
And i use this for load cars, and load cars, but some times the files becomes equal,
and spawn 2x the same car, Sorry my bad english...

Код:
public LoadDynamicCars()
{
	new File: file = fopen("Sistema/Cars/carspawns.cfg", io_read);
	if (file)
	{
		new idx = 1;
		while (idx < sizeof(DynamicCars))
		{

			new LoadCars[256];
  			format(LoadCars,sizeof(LoadCars),"Sistema/Cars/All/%d.ini",idx);
  			
			DynamicCars[idx][CarModel] = dini_Int(LoadCars, "CarModel");
			DynamicCars[idx][CarX] = dini_Int(LoadCars, "CarX");
			DynamicCars[idx][CarY] = dini_Int(LoadCars, "CarY");
			DynamicCars[idx][CarZ] = dini_Int(LoadCars, "CarZ");
			DynamicCars[idx][CarAngle] = dini_Int(LoadCars, "CarAngle");
			DynamicCars[idx][CarColor1] = dini_Int(LoadCars, "CarColor1");
			DynamicCars[idx][CarColor2] = dini_Int(LoadCars, "CarColor2");
			DynamicCars[idx][FactionCar] = dini_Int(LoadCars, "FactionCar");
			DynamicCars[idx][CarType] = dini_Int(LoadCars, "CarType");
			DynamicCars[idx][cOwner] = dini_Int(LoadCars, "cOwner");
			DynamicCars[idx][cDescription] = dini_Int(LoadCars, "cDescription");
			DynamicCars[idx][cValue] = dini_Int(LoadCars, "cValue");
			DynamicCars[idx][cOwned] = dini_Int(LoadCars, "cOwned");
			DynamicCars[idx][cLock] = dini_Int(LoadCars, "cLock");
			
			new Plate[22];
			format(Plate,22,"RC-%d-RP",GetPlayerVehicleID(idx));
			SetVehicleNumberPlate(idx,Plate);
			SetVehicleToRespawn(idx);
			new vehicleid = CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);

			if(DynamicCars[idx][FactionCar] != 255)
			{
				format(Plate,22,"RC-%d-RP",GetPlayerVehicleID(idx));
				SetVehicleNumberPlate(vehicleid,Plate);
				SetVehicleToRespawn(vehicleid);
			}
			idx++;
		}
		fclose(file);
	}
	return 1;
}
Reply
#2

Help me please!
Reply
#3

You are using a weird way for this,
the loading has no working loop
Reply
#4

Quote:
Originally Posted by milanosie
Посмотреть сообщение
You are using a weird way for this,
the loading has no working loop
I'm using dini
Reply
#5

dini has nothing to do with a loop

Example for loading: (NOTE: EXAMPLE. SELF MADE, THE ONE I USE)

pawn Код:
forward LoadVehicles();
public LoadVehicles()
{
    for(new i = 1; i < sizeof(CarInfo); i++)
    {
    format(file4,sizeof(file4), "realityrp/vehicles/%d.ini", i);
    if(fexist(file4))
    {
        CarInfo[i][model] = dini_Int(file4, "model");
        CarInfo[i][owner] = dini_Int(file4, "owner");
        CarInfo[i][forsale] = dini_Int(file4, "forsale");
        CarInfo[i][vehx] = dini_Int(file4, "vehx");
        CarInfo[i][vehy] = dini_Int(file4, "vehy");
        CarInfo[i][vehz] = dini_Int(file4, "vehz");
        CarInfo[i][rot] = dini_Int(file4, "rot");
        CarInfo[i][vcol1] = dini_Int(file4, "vcol1");
        CarInfo[i][vcol2] = dini_Int(file4, "vcol2");
        CarInfo[i][Carid] = dini_Int(file4, "Carid");
        CarInfo[i][CarLock] = dini_Int(file4, "CarLock");
        strmid(CarInfo[i][OwnerName], dini_Get(file4,"OwnerName"), 0, strlen(dini_Get(file4,"OwnerName")), 255);
        CarInfo[i][OwnerName] =  strmid(CarInfo[i][OwnerName], dini_Get(file4,"OwnerName"), 0, strlen(dini_Get(file4,"OwnerName")), 256);
        ownablecar = CreateVehicle(CarInfo[i][model], CarInfo[i][vehx], CarInfo[i][vehy], CarInfo[i][vehz], CarInfo[i][rot], CarInfo[i][vcol1], CarInfo[i][vcol2], 600000000000);
        vehiforsale[ownablecar] = CarInfo[i][forsale];
        vehiprice[ownablecar] = CarInfo[i][Vehprice];
        vehilocked[ownablecar] = CarInfo[i][CarLock];
        CarInfo[i][Vehprice] = dini_Int(file4, "Vehprice");
        if(vehilocked[ownablecar] == 1)
        {
                GetVehicleParamsEx(ownablecar,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(ownablecar,engine,lights,alarm,true,bonnet,boot,objective);
        }
        else
        {
                GetVehicleParamsEx(ownablecar,engine,lights,alarm,doors,bonnet,boot,objective);
                SetVehicleParamsEx(ownablecar,engine,lights,alarm,false,bonnet,boot,objective);
        }
        if(vehiforsale[ownablecar] == 1)
        {
            new string[128];
            format(string, sizeof(string), "Price: %d\nUse /buycar to buy this vehicle!",CarInfo[i][Vehprice]);
            VehicleLabel[i] = Create3DTextLabel(string ,COLOR_ORANGE, CarInfo[i][vehx],CarInfo[i][vehy],CarInfo[i][vehz],20, 0, 1);
        }
    }
    }
    return 1;
}
Reply
#6

i need help!
Reply
#7

You are opening the same file twice. If using dini (which I do not recommend using at all) you do not need to specifically call fopen.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
You are opening the same file twice. If using dini (which I do not recommend using at all) you do not need to specifically call fopen.
I try resolve problem and now have this
but the bug continue..

pawn Код:
public LoadDynamicCars()
{

        for(new idx = 1; idx < sizeof(DynamicCars); idx++)
         {


            new LoadCars[256];
            format(LoadCars,sizeof(LoadCars),"Sistema/Cars/All/%d.ini",idx);
       if(fexist(LoadCars))
    {

            DynamicCars[idx][CarModel] = dini_Int(LoadCars, "CarModel");
            DynamicCars[idx][CarX] = dini_Int(LoadCars, "CarX");
            DynamicCars[idx][CarY] = dini_Int(LoadCars, "CarY");
            DynamicCars[idx][CarZ] = dini_Int(LoadCars, "CarZ");
            DynamicCars[idx][CarAngle] = dini_Int(LoadCars, "CarAngle");
            DynamicCars[idx][CarColor1] = dini_Int(LoadCars, "CarColor1");
            DynamicCars[idx][CarColor2] = dini_Int(LoadCars, "CarColor2");
            DynamicCars[idx][FactionCar] = dini_Int(LoadCars, "FactionCar");
            DynamicCars[idx][CarType] = dini_Int(LoadCars, "CarType");
            DynamicCars[idx][cOwner] = dini_Int(LoadCars, "cOwner");
            DynamicCars[idx][cDescription] = dini_Int(LoadCars, "cDescription");
            DynamicCars[idx][cValue] = dini_Int(LoadCars, "cValue");
            DynamicCars[idx][cOwned] = dini_Int(LoadCars, "cOwned");
            DynamicCars[idx][cLock] = dini_Int(LoadCars, "cLock");
            //idx++;
           
            new Plate[22];
            format(Plate,22,"RC-%d-RP",GetPlayerVehicleID(idx));
            SetVehicleNumberPlate(idx,Plate);
            SetVehicleToRespawn(idx);
            new vehicleid = CreateVehicle(DynamicCars[idx][CarModel],DynamicCars[idx][CarX],DynamicCars[idx][CarY],DynamicCars[idx][CarZ],DynamicCars[idx][CarAngle],DynamicCars[idx][CarColor1],DynamicCars[idx][CarColor2], -1);

            if(DynamicCars[idx][FactionCar] != 255)
            {
                format(Plate,22,"RC-%d-RP",GetPlayerVehicleID(idx));
                SetVehicleNumberPlate(vehicleid,Plate);
                SetVehicleToRespawn(vehicleid);
            }
        }
        }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)