My mode cause lags and i think i know the reason
#1

I have mode with dynamic car system and this is the code which create the cars from the script files:
Код:
		if(dini_Exists(CarFile(v)))
		{
	       	AddStaticVehicleEx(dini_Int(CarFile(v),"Model"),dini_Float(CarFile(v),"X"),dini_Float(CarFile(v),"Y"),dini_Float(CarFile(v),"Z"),dini_Float(CarFile(v),"A"),dini_Int(CarFile(v),"Color1"),dini_Int(CarFile(v),"Color2"),1000*60*60*24*31*6);
	       	SetVehicleVirtualWorld(v, dini_Int(CarFile(v),"VirtualWorld"));
	       	if(!CanPaintJob(v))
			{
			    if(dini_Int(CarFile(v),"Paintjob") != -1)
			    {
			        dini_Unset(CarFile(v),"Paintjob");
				}
			}
		   	ChangeVehiclePaintjob(v,dini_Int(CarFile(v),"Paintjob"));
			VehicleWindows[v][0] = 0;
			VehicleWindows[v][1] = 0;
			VehicleWindows[v][2] = 0;
			VehicleWindows[v][3] = 0;
            new engine,lights,alarm,doors,bonnet,boot,objective;
			GetVehicleParamsEx(v,engine,lights,alarm,doors,bonnet,boot,objective);
		    new Float:vehx, Float:vehy, Float:vehz, Float:veha;
		    GetVehiclePos(v, vehx, vehy, vehz);
		    GetVehicleZAngle(v,veha);
		    Siran[v] = false;
		    MicNums[v] = 3;
		    Oil[v] = 70;
		    Fuel[v] = 100;
			CarInfo[v][vLock] = 1;
			CarInfo[v][vLtrunk] = 0;
			CarInfo[v][vLhood] = 0;
			CarInfo[v][vColor1] = dini_Int(CarFile(v),"Color1");
			CarInfo[v][vColor2] = dini_Int(CarFile(v),"Color2");
			ChangeVehicleColor(v,CarInfo[v][vColor1],CarInfo[v][vColor2]);
			CarInfo[v][Location] = dini_Int(CarFile(v),"Location");
			CarInfo[v][Insurance] = dini_Int(CarFile(v),"Insurance");
			CarInfo[v][vSpawnX] = dini_Float(CarFile(v),"X");
			CarInfo[v][vSpawnY] = dini_Float(CarFile(v),"Y");
		 	CarInfo[v][vSpawnZ] = dini_Float(CarFile(v),"Z");
			CarInfo[v][vSpawnA] = dini_Float(CarFile(v),"A");
			CarInfo[v][vOSpawnX] = dini_Float(CarFile(v),"X");
			CarInfo[v][vOSpawnY] = dini_Float(CarFile(v),"Y");
		 	CarInfo[v][vOSpawnZ] = dini_Float(CarFile(v),"Z");
			CarInfo[v][vOSpawnA] = dini_Float(CarFile(v),"A");
			AddVehicleComponent(v,dini_Int(CarFile(v),"SPOILER"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"HOOD"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"ROOF"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"SIDESKIRT"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"LAMPS"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"NITRO"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"EXHAUST"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"WHEELS"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"STEREO"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"HYDRAULICS"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"FRONT_BUMPER"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"REAR_BUMPER"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"VENT_RIGHT"));
			AddVehicleComponent(v,dini_Int(CarFile(v),"VENT_LEFT"));
			for(new i = 0; i <= 13;i++)
				CarInfo[v][Improve][i] = GetVehicleComponentInSlot(v,i);
			W8[v] = false;
			vHaveC4[v] = false;
			SetTimerEx("SpikeTires",500,true,"i",v);
			//-------------------------------
			if(IsAPlane(v))
			{
			    CarInfo[v][Manoa] = 5;
			}
			else if(!IsABike(v) && !IsAVehicleForSell(v) && !IsAPlane(v))
			{
				if(IsAPoliceCar(v) || IsACoastBoat(v) || IsAChifeCar(v) || IsAGarageCar(v) || IsAPrisonCar(v) || IsAFireCar(v) || IsANewsCar(v) ||
				IsAMedicCar(v) || IsATrashCar(v) || IsAFisherBoat(v) || IsABicycle(v))
				{
					CarInfo[v][Manoa] = 5;
				}
				if(IsADmvTruck(v) || IsADmvCar(v) || IsADmvTaxi(v) || IsADmvBoat(v))
				{
					CarInfo[v][Manoa] = 2;
				}
			}
			else if(IsABike(v) && !IsAVehicleForSell(v))
			{
				if(IsAPoliceCar(v) || IsACoastBoat(v) || IsAChifeCar(v) || IsAGarageCar(v) || IsAPrisonCar(v) || IsAFireCar(v) || IsANewsCar(v) ||
				IsAMedicCar(v) || IsAPizzaBike(v) || IsATrashCar(v) || IsAFisherBoat(v) || IsABicycle(v))
				{
					CarInfo[v][Manoa] = 5;
				}
				else if(IsADmvFastBike(v))
				{
				    CarInfo[v][Manoa] = 5;
				}
				else if(IsADmvSlowBike(v))
				{
				    CarInfo[v][Manoa] = 3;
				}
			}
			else if(IsAVehicleForSell(v))
			{
				if(dini_Isset(CarFile(v),"Manoa"))
				{
					CarInfo[v][Manoa] = dini_Int(CarFile(v),"Manoa");
				}
				else
				{
					CarInfo[v][Manoa] = 1;
				}
			}
			else
			{
				CarInfo[v][Manoa] = dini_Int(CarFile(v),"Manoa");
			}
			//-------------------------------
			if(IsABicycle(v))
			{
				SetVehicleParamsEx(v,0,0,alarm,0,bonnet,CarInfo[v][vLtrunk],objective);
			}
			else if(IsAPoliceCar(v)||IsACoastBoat(v)||IsAChifeCar(v)||IsAGarageCar(v)||IsAPrisonCar(v)||IsAFireCar(v)||IsANewsCar(v)||IsAMedicCar(v))
			{
				SetVehicleParamsEx(v,0,0,alarm,CarInfo[v][vLock],bonnet,CarInfo[v][vLtrunk],objective);
			}
			else if(IsAPizzaBike(v)||IsATrashCar(v)||IsAFisherBoat(v))
			{
			    SetVehicleParamsEx(v,0,0,alarm,CarInfo[v][vLock],bonnet,CarInfo[v][vLtrunk],objective);
			}
			else if(IsADmvPlane(v)||IsADmvTruck(v)||IsADmvFastBike(v)||IsADmvCar(v)||IsADmvTaxi(v)||IsADmvBoat(v)||IsADmvSlowBike(v))
			{
				SetVehicleParamsEx(v,1,1,alarm,0,bonnet,CarInfo[v][vLtrunk],objective);
			}
			else if(IsAVehicleForSell(v))
			{
				SetVehicleParamsEx(v,0,0,alarm,0,bonnet,CarInfo[v][vLtrunk],objective);
			}
			else
			{
			    SetVehicleParamsEx(v,0,0,alarm,CarInfo[v][vLock],bonnet,CarInfo[v][vLtrunk],objective);
			}
		    if(CanPaintJob(v))ChangeVehiclePaintjob(v,dini_Int(CarFile(v),"Paintjob"));
		    ChangeVehicleColor(v,dini_Int(CarFile(v),"Color1"),dini_Int(CarFile(v),"Color2"));
		    if(dini_Int(CarFile(v),"Model") == 544)
		    {
				if(IsAFireCar(v)){
		        XLadder[v] = -49.099822;
				ZLadder[v] = 180.0;
		        Ladder[v] = CreateObject(12950,0,0,0,0,0,0,500);
				AttachObjectToVehicle(Ladder[v],v,-0.019999,0.000000,1.319999,XLadder[v],0.000000,ZLadder[v]);}
		    }
		    if(IsAPoliceCar(v))
		    {
		        siran[v] = CreateObject(18646,999,999,999,999,999,999,500);
		    }
		    if(dini_Int(CarFile(v),"Model") == 544)
		    {
		        siran[v] = CreateObject(18646,999,999,999,999,999,999,500);
		    }
		    if(dini_Int(CarFile(v),"Model") == 578)
		    {
		        if(IsAGarageCar(v))
		        {
		        	AttachObjectToVehicle(CreateObject(983,999,999,999,999,999,999,500), v, 1.349999, -2.299998, 0.350000, 0.000000, 0.000000, 0.000000);
		        	AttachObjectToVehicle(CreateObject(983,999,999,999,999,999,999,500), v, 1.349999, -0.700000, 0.350000, 0.000000, 0.000000, 0.000000);
		        	AttachObjectToVehicle(CreateObject(983,999,999,999,999,999,999,500), v, -1.349999, -2.299998, 0.350000, 0.000000, 0.000000, 0.000000);
		        	AttachObjectToVehicle(CreateObject(983,999,999,999,999,999,999,500), v, -1.349999, -0.700000, 0.350000, 0.000000, 0.000000, 0.000000);
		        }
		    }

			new liceplate[256];
			if(dini_Isset(CarFile(v),"PlateNumber"))
		    {
				set(liceplate,"%d",dini_Int(CarFile(v),"PlateNumber"));
		        SetVehicleNumberPlate(v,liceplate);
				CarInfo[v][vPlate] = dini_Int(CarFile(v),"PlateNumber");
		    }
		    else
		    {
		        new string[512];
				for(new i = 0; i < 1000; i++)
				{
				    LicePlate[v] = 1000000+random(6777777);
				    set(string,"%d",LicePlate[v]);
				    if(!dini_Isset("Other/LicePlate.txt",string))
					{
					    dini_IntSet("Other/LicePlate.txt",string,v);
					    dini_IntSet(CarFile(v),"PlateNumber",LicePlate[v]);
					    set(liceplate,"%d",LicePlate[v]);
						SetVehicleNumberPlate(v,liceplate);
						CarInfo[v][vPlate] = LicePlate[v];
						break;
					}
				}
			}
			SetVehicleToRespawn(v);
			SpawnVehicle(v,1);
			SetVehicleParamsEx(v,0,0,0,CarInfo[v][vLock],0,0,0);
			FixVehicle(v);
			SetCarHP(v,1000.0);
		}
i have 384 cars in my server and it cause many lags!

this is the code of car:
Код:
Model=596
X=1535.854125
Y=-1677.464721
Z=13.102901
A=0.000000
Owner=police
Color1=0
Color2=1
PlateNumber=2792974
please help me to solve this lags pleasE!
Reply


Messages In This Thread
My mode cause lags and i think i know the reason - by gahal156 - 04.05.2012, 20:20
Re: My mode cause lags and i think i know the reason - by WarriorEd22 - 04.05.2012, 22:35
Re: My mode cause lags and i think i know the reason - by SA+MP - 04.05.2012, 23:28
Re: My mode cause lags and i think i know the reason - by gahal156 - 05.05.2012, 09:39
Re: My mode cause lags and i think i know the reason - by gahal156 - 06.05.2012, 18:06

Forum Jump:


Users browsing this thread: 1 Guest(s)