Fuel consumption system?
#1

Hello.

Do you have a fuel consumption system?

For example if I'm Sultan, I will eat X liters/100 km

If I am Infernus, I'll eat a little etc.

Take the speed of the vehicle also note ...

++

https://www.youtube.com/watch?v=hWHM90RYqjg
Reply
#2

Have you tried googling it? I've found a lot of those scripts https://www.******.nl/webhp?sourceid...0system%20samp
Reply
#3

I have look this:

https://www.youtube.com/watch?v=hWHM90RYqjg

How to make this system?
Reply
#4

UP, please
Reply
#5

this may help:
http://forum.sa-mp.com/showthread.ph...93892#poststop
Reply
#6

Yes, but it's not this system:

https://www.youtube.com/watch?v=hWHM90RYqjg
Reply
#7

up, please.
Reply
#8

You can use GetVehicleVelocity to check a vehicle's speed, or for acceleration, check if the player is holding W while in a vehicle with OnPlayerKeyStateChange.
Reply
#9

You can try making your own array with consumption rates for each vehicle, and multiply that rate by the vehicle's speed to get a resultant consumption rate.
pawn Код:
new Float: VehicleFuelConsumptionRate[][] =
{
    {560.0, 1.0}, //  Sultan (560) will consume at full rate (100%)
    {411.0, 1.0}, // Infernus (411) will consume at full rate (100%)
    {562.0, 0.5}, // Elegy (562) will consume at half rate (50%)
    {565.0, 0.2} // Flash (565) will consume at very low rate (20%)
};

Float: GetVehicleConsumptionPerSecond(vehicleid)
{
    new Float: rate = 1;
    for(new i = 0; i != sizeof VehicleFuelConsumptionRate; i += 1)
    {
        if(vehicleid == floatround(VehicleFuelConsumptionRate[i][0]))
        {
            // We're assuming GetVehicleSpeed returns a KM/H value.
            // Divide Km/h by 3600 to get KM/s.
            rate = (GetVehicleSpeed(vehicleid)/3600)*VehicleFuelConsumptionRate[i][1];
            break;
        }
    }
    return rate;
}

// Somewhere else, every 1 second...
Fuel -= GetVehicleConsumptionPerSecond(vehicleid);
Please, understand you have to put your own logic and work into this.
Reply
#10

My GetVehicleSpeed:

pawn Код:
forward GetVehicleSpeed(vehicleid);
public GetVehicleSpeed(vehicleid)
{
    new Float:X,
        Float:Y,
        Float:Z;
       
    GetVehicleVelocity(vehicleid, X, Y, Z);
   
    return floatround(floatsqroot(X * X + Y * Y + Z * Z) * 180);
}
It's good?

By cons I do not understand the code.

Per second, the Sultan will lose how many liters? It is with the 100% that I'm a bit stuck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)