Fuel System - No Fuel - 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: Fuel System - No Fuel (
/showthread.php?tid=592854)
Fuel System - No Fuel -
Scottylad - 30.10.2015
Nevermind, going to re-do the system from scratch to make sure there is no bugs!
Re: Fuel System - No Fuel -
ATGOggy - 30.10.2015
You need to set the fuel of the vehicle somewhere in the script. Gas[vehicleid]=100.0;
Re: Fuel System - No Fuel -
feartonyb - 30.10.2015
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
Re: Fuel System - No Fuel -
Scottylad - 31.10.2015
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;
}