Fuel System - No Fuel
#1

Nevermind, going to re-do the system from scratch to make sure there is no bugs!
Reply
#2

You need to set the fuel of the vehicle somewhere in the script. Gas[vehicleid]=100.0;
Reply
#3

Make a check if it's a faction vehicle

Код:
if(!IsAFactionVehicle(vehicleid))
{
	if(Gas[vehicleid] < 1.0)
	{
		SendClientMessage(playerid, COLOR_RED, "[!ERROR] Your vehicle is out of fuel, it won't start!");
	}
}
and than make a function

Код:
stock IsAFactionVehicle(vehicleid))
{
	if(vehicleid == ... || vehicleid == ...) return true;
	return false;
}
Replace "..." with vehicle IDs of your faction vehicles
Reply
#4

I've fixed it now but when I do /car engine - it says there is no fuel in the tank yet I've placed 100.00 fuel into the vehicle and placed that if it is smaller or equal to 1.0 fuel it will not start:

Код:
forward SetVehicleEngine(vehicleid, playerid);
public SetVehicleEngine(vehicleid, playerid)
{
	new string[128];
	new engine,lights,alarm,doors,bonnet,boot,objective;
    GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
    if(engine == VEHICLE_PARAMS_ON)
	{
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SERVER] Vehicle engine stopped successfully.");
		arr_Engine{vehicleid} = 0;
	}
    else if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET)
	{
		new
			Float: f_vHealth;

		GetVehicleHealth(vehicleid, f_vHealth);
		if(f_vHealth < 350.0) return SendClientMessage(playerid, COLOR_RED, "The car won't start - it's totalled!");
	    if(VehicleFuel[vehicleid] <= 1.0) return SendClientMessage(playerid, COLOR_RED, "The car won't start - there's no fuel in the tank!");
		SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
		SendClientMessage(playerid, COLOR_LIGHTBLUE, "[SERVER] Vehicle engine started successfully (/car engine to turn the engine off).");
		arr_Engine{vehicleid} = 1;
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)