Will this loop cause any issues with lag? Vehicle Fuel.
#2

So basically why saving the vehicle fuel every 30 seconds while it did already save? Here is a small check.

Код:
native IsValidVehicle(vehicleid);

static
	bool:V_cansave[MAX_VEHICLES char];

public FuelUpdate()
{
	for (new i = 0; i != MAX_VEHICLES; i++)
	{
		if (!IsValidVehicle(i))
			continue;

		new 
			engine, 
			lights, 
			alarm, 
			doors, 
			bonnet, 
			boot, 
			objective
		;

		GetVehicleParamsEx(i, engine, lights, alarm, doors, bonnet, boot, objective);
		
		if (engine)
		{
			if (VehFuel[i] > 0) {
				V_cansave{i} = true;
				VehFuel[i]--;
			}

			if (!VehFuel[i])
			{
				SetVehicleParamsEx(i, 0, lights, alarm, doors, bonnet, boot, objective);
				
				if (VehicleSQLID[i] > 0) 
				{
					if (V_cansave{i})
					{
						V_cansave{i} = false;
						MySQL_SetInteger(VehicleSQLID[i], "VehFuel", 0, "vehicles");
					}
				}
			}
		}
	}
}
Reply


Messages In This Thread
Will this loop cause any issues with lag? Vehicle Fuel. - by Dokins - 27.06.2015, 21:00
Re: Will this loop cause any issues with lag? Vehicle Fuel. - by Evocator - 27.06.2015, 21:23
Re: Will this loop cause any issues with lag? Vehicle Fuel. - by Dokins - 27.06.2015, 22:35
Re: Will this loop cause any issues with lag? Vehicle Fuel. - by kyriakos587 - 27.06.2015, 22:45
Re: Will this loop cause any issues with lag? Vehicle Fuel. - by Dokins - 27.06.2015, 22:59

Forum Jump:


Users browsing this thread: 1 Guest(s)