SA-MP Forums Archive
Lag problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lag problem (/showthread.php?tid=609712)



Lag problem - sampkinq - 15.06.2016

Hi, when the cars spawn much lag. What is the problem ?
I'm sorry for my bad English.


Code:
public OnVehicleSpawn(vehicleid)
{
for(new h = 1; h < MAX_EV; h++)
{
	    for(new x = 1; x < _a@SL; x++)
		{
		    if(EvIslem[h][aracCount][x] != 0)
		    {
		    
		        ChangeVehicleColor(EvIslem[h][aracCount][x], EvIslem[h][aracRenk1][x],EvIslem[h][aracRenk2][x]);
		    
            	if(EvIslem[h][aracPaintjobuVarmi][x] != 0)
				{
				ChangeVehiclePaintjob(EvIslem[h][aracCount][x], EvIslem[h][aracPaintjob][x]);
				}
				
				for (new i; i < 14; i++)
				{
				RemoveVehicleComponent(EvIslem[h][aracCount][x], GetVehicleComponentInSlot(EvIslem[h][aracCount][x], i));
				}
				
				if(EvIslem[h][aracModifiyeParca1][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca1][x]);
				}
				if(EvIslem[h][aracModifiyeParca2][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca2][x]);
				}
				if(EvIslem[h][aracModifiyeParca3][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca3][x]);
				}
				if(EvIslem[h][aracModifiyeParca4][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca4][x]);
				}
				if(EvIslem[h][aracModifiyeParca5][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca5][x]);
				}
				if(EvIslem[h][aracModifiyeParca6][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca6][x]);
				}
				if(EvIslem[h][aracModifiyeParca7][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca7][x]);
				}
				if(EvIslem[h][aracModifiyeParca8][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca8][x]);
				}
				if(EvIslem[h][aracModifiyeParca9][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca9][x]);
				}
				if(EvIslem[h][aracModifiyeParca10][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca10][x]);
				}
				if(EvIslem[h][aracModifiyeParca11][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca11][x]);
				}
				if(EvIslem[h][aracModifiyeParca12][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca12][x]);
				}
				if(EvIslem[h][aracModifiyeParca13][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca13][x]);
				}
				if(EvIslem[h][aracModifiyeParca14][x] != 0)
				{
				AddVehicleComponent(EvIslem[h][aracCount][x], EvIslem[h][aracModifiyeParca14][x]);
				}
			}
		}
	}
    return 1;
}



Re: Lag problem - GangstaSunny - 15.06.2016

Simply: To many "for"`s.