Jump to content

What is the best way to do a fuel script?


Recommended Posts

Right now I'm working on when a player enters a car, start a timer to run in 1 second from then, and run once, and then every time the function for that timer is called, call another timer to re-do that function once more every time, basically so an exit car call isn't needed. The way I'm currently calculating fuel depletion is like this...

local speedX, speedY, speedZ = getElementVelocity(vehicle); 
vel = (speedX^2 + speedY^2 + speedZ^2)^(0.5)+(math.random(100,1000)/25000); 
local remainingFuel = takeCarFuel(vehicle,vel); 
  

That takes fuel off depending on velocity and then a little more extra, so if you're not moving it still takes a bit off you for idling.

Does anyone have any thoughts on a better system?

Link to comment
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...