Vehicle system help
#1

I am creating a vehicle system and in the system i am creating a dealership where it checks for the cars status to see if it is for sale. Then it spawns the car in a certain location. but when i load the server it keeps placing the car in all of the spots instead of just one. her'es my load car script:
Код:
stock LoadCar()
{
    if(!fexist("car.cfg")) fcreate("car.cfg");
	new cinfo[23][32];
	new string[256];
	new File:file = fopen("car.cfg", io_read);
	if(file)
	{
	    new idx = 1;
		while(idx < MAX_CAR)
		{
		    fread(file, string);
		    split(string, cinfo, '|');
		    CarInfo[idx][cStatus] = strval(cinfo[0]);
		    CarInfo[idx][cDealership] = strval(cinfo[1]);
		    format(CarInfo[idx][cOwner], 32, "%s", cinfo[2]);
		    CarInfo[idx][cX] = floatstr(cinfo[3]);
		    CarInfo[idx][cY] = floatstr(cinfo[4]);
		    CarInfo[idx][cZ] = floatstr(cinfo[5]);
		    CarInfo[idx][cAngle] = floatstr(cinfo[6]);
		    CarInfo[idx][cModel] = strval(cinfo[7]);
		    CarInfo[idx][cColor1] = strval(cinfo[8]);
		    CarInfo[idx][cColor2] = strval(cinfo[9]);
		    CarInfo[idx][cCost] = strval(cinfo[10]);
		    format(CarInfo[idx][cLicensePlate], 32, "%s", cinfo[11]);

		    CarInfo[idx][cMod1] = strval(cinfo[12]); // PaintJobs
		    CarInfo[idx][cMod2] = strval(cinfo[13]); // Exausts
		    CarInfo[idx][cMod3] = strval(cinfo[14]); // Front bumber
		    CarInfo[idx][cMod4] = strval(cinfo[15]); // Front bullbar
		    CarInfo[idx][cMod5] = strval(cinfo[16]); // Rear bullbar
		    CarInfo[idx][cMod6] = strval(cinfo[17]); // Sideskirt
		    CarInfo[idx][cMod7] = strval(cinfo[18]); // Wheels
		    CarInfo[idx][cMod8] = strval(cinfo[19]); // Stereo
		    CarInfo[idx][cMod9] = strval(cinfo[20]); // Hydraulics
		    CarInfo[idx][cMod10] = strval(cinfo[21]); // Nitro
		    CarInfo[idx][cDealerSpawned] = 0;
			idx++;
	    }
	}
	print("Cars loaded successfully.");
	LoadCarComponents();
	return 1;
}
Here is my load components script which spawns the car into the dealership which statrs towards the end:
Код:
stock LoadCarComponents()
{
		for(new idx=1; idx<MAX_CAR; idx++)
		{
		    if(CarInfo[idx][cStatus] == 1 && CarInfo[idx][cDealership] == 0)
		    {
		    	CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], CarInfo[idx][cX], CarInfo[idx][cY], CarInfo[idx][cZ], CarInfo[idx][cAngle], CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
	    		SetVehicleNumberPlate(CarInfo[idx][cVID], CarInfo[idx][cLicensePlate]);
                if(CarInfo[idx][cMod1] > -1)
	    		{
	    			ChangeVehiclePaintjob(CarInfo[idx][cVID], CarInfo[idx][cMod1]); // PaintJobs
	    		}
				if(CarInfo[idx][cMod2] > -1)
				{
                    AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod2]); // Exausts
				}
	    		if(CarInfo[idx][cMod3] > -1)
				{
	    		    AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod3]); // Front bumber
				}
	    		if(CarInfo[idx][cMod4] > -1)
	    		{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod4]); // Front bullbar
	    		}
	    		if(CarInfo[idx][cMod5] > -1)
				{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod5]); // Rear bullbar
				}
	    		if(CarInfo[idx][cMod6] > -1)
	    		{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod6]); // Sideskirt
	    		}
	    		if(CarInfo[idx][cMod7] > -1)
				{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod7]); // Wheels
	    		}
	    		if(CarInfo[idx][cMod8] > -1)
	    		{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod8]); // Stereo
	    		}
	    		if(CarInfo[idx][cMod9] > -1)
				{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod9]); // Hydraulics
	    		}
	    		if(CarInfo[idx][cMod10] > -1)
	    		{
	    			AddVehicleComponent(CarInfo[idx][cVID], CarInfo[idx][cMod10]); // Nitro
	    		}
		    }
		    if(CarInfo[idx][cStatus] = 2 && CarInfo[idx][cDealership] != 0 && CarInfo[idx][cDealerSpawned] == 0)
    		{
		    	if(CarInfo[idx][cDealership] = 1)
 		    	{
        			if(d1Cars <= 9)
		        	{
						if(d1Spot1 == 0)
						{
                            	CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2135.2371,-1126.2520,25.2916,90.6277, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            	d1Spot1 = 1;
                            	d1Cars ++;
                            	CarInfo[idx][cDealerSpawned] = 1;
                            	print("Dealership 1 Spot 1 loaded");
						}
					    if(d1Spot2 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2135.2156,-1130.7583,25.7717,91.3779, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot2 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 2 loaded");
						}
					    if(d1Spot3 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2135.1309,-1135.3234,25.5778,89.0913, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot3 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 3 loaded");
						}
						if(d1Spot4 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2134.9939,-1140.4423,25.3797,88.8326, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot4 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 4 loaded");
						}
						if(d1Spot5 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2134.9253,-1145.0653,24.5648,87.7366, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot5 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 5 loaded");
						}
						if(d1Spot6 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2119.3481,-1146.9949,24.5604,268.3087, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot6 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 6 loaded");
						}
						if(d1Spot7 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2119.8662,-1142.7505,24.5735,264.1833, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot7 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 7 loaded");
						}
						if(d1Spot8 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2120.1868,-1138.1370,25.1993,266.5604, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot8 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 8 loaded");
						}
						if(d1Spot9 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2120.3767,-1133.8942,25.1044,267.0581, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot9 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 9 loaded");
						}
						if(d1Spot10 == 0)
						{
                            CarInfo[idx][cVID] = CreateVehicle(CarInfo[idx][cModel], 2120.1238,-1129.8496,25.4451,269.3587, CarInfo[idx][cColor1], CarInfo[idx][cColor2], -1);
                            d1Spot10 = 1;
                            d1Cars ++;
                            CarInfo[idx][cDealerSpawned] = 1;
                            print("Dealership 1 Spot 10 loaded");
						}
      				}
    		    }
    		    if(CarInfo[idx][cDealership] = 2)
    		    {

				}
  			}

		}
		print("Car Components loaded successfully.");

}
Thank You
Reply


Messages In This Thread
Vehicle system help - by jeffery30162 - 18.03.2014, 19:21
Re: Vehicle system help - by jeffery30162 - 18.03.2014, 23:30

Forum Jump:


Users browsing this thread: 1 Guest(s)