23.06.2015, 13:38
Is it possible to make fuel system so example Trucks have 100L tank or Cars have 50L motors 25L and Buses 80L tank. Is it possible to make that and how should I do it any suggestions?
public OnFilterScriptInit()//when the filterscript loads { for(new i=0;i<MAX_VEHICLES;i++) { fuel[i] = 100; //sets every car's fuel to 100 in a loop } SetTimer("timer_fuel_lower",4200,true); //sets the timer to drop the fuel return 1; }
//On top of script, but after #include(s)
#define FuelRoadTrain 100
OnPlayerStateChange(...)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleId
if(GetVehicleModel(vehicleid) == 515)
{
//Now here you need to calculate the speed of the vehicle and refuce the fuel from it
new Float:speed_x, Float:speed_y, Float:speed_z, Float:final_speed, final_speed_int;
// Get the vehicles velocity
GetVehicleVelocity(vehicleid, speed_x, speed_y, speed_z);
// Calculate the speed
final_speed = floatsqroot(((speed_x * speed_x) + (speed_y * speed_y)) + (speed_z * speed_z)) * 158.179;
// Convert the float value to an int value
final_speed_int = floatround(final_speed, floatround_round);
if ((final_speed_int > 10) && (AVehicleData[vehicleid][Fuel] > 0))
{
AVehicleData[vehicleid][Fuel] = AVehicleData[vehicleid][Fuel] -1; // Decrease the fuel for this vehicle every time the timer is run
}
}
}
}
}