Jump to content

FUEL SYSTEM


lockdw

Recommended Posts

  

47 minutes ago, lockdw said:

Guys, how can i exclude some vehicles from the fuel script? Like, exclude the job's cars from the fuel system ? 

http://www.mediafire.com/file/gxw58nfvpawx72a/ir-gasolina.zip/file

Here's the script link.

 

 

  

local BlockedModel = {
  -- [Car id] = true,
	[411] = true,
	[457] = true,
}

if not BlockedModel[getElementModel ( v )] then 
	-- Bla Bla Bla  
end

 

 

Edited by Simple.
Link to comment

I suggest that you tell the client whenever he enters a vehicle whether it is a job car or not from serverside. Then you start drawing the HUD after you received that server event. Your script seems pretty big but it should not be too hard.

Link to comment
7 hours ago, Simple. said:

  

  


local BlockedModel = {
  -- [Car id] = true,
	[411] = true,
	[457] = true,
}

if not BlockedModel[getElementModel ( v )] then 
	-- Bla Bla Bla  
end

 

 

It doesn't work... Where should i paste this ?

 

7 hours ago, Simple. said:

  

  


local BlockedModel = {
  -- [Car id] = true,
	[411] = true,
	[457] = true,
}

if not BlockedModel[getElementModel ( v )] then 
	-- Bla Bla Bla  
end

 

 

What about this message ? https://prnt.sc/rg4d33

Link to comment
8 hours ago, lockdw said:

It doesn't work... Where should i paste this ?

 

What about this message ? https://prnt.sc/rg4d33

server/main.Lua

 

factor = 0.03
local BlockedModel = {
	-- [Car id] = true,
	  [411] = true,
	  [457] = true,
  }

function createVehicles(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		fuel = math.random(70,80)
		setElementData(v, "fuel", fuel)
	end
end

function processFuel(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		if not BlockedModel[getElementModel ( v )] then 
			local fuel = getElementData(v, "fuel") or math.random(70,80)
			if (getVehicleEngineState(v) and fuel > 0 ) then
				fuel = fuel - factor
			end
			if (fuel <= 0.99) then
				fuel = 0
				setVehicleEngineState(v, false)
				
			end
			setElementData(v, "fuel", fuel)
		end
	end
end

createVehicles()
setTimer(processFuel, 1000, 0)

 

Link to comment
5 hours ago, Simple. said:

server/main.Lua

 


factor = 0.03
local BlockedModel = {
	-- [Car id] = true,
	  [411] = true,
	  [457] = true,
  }

function createVehicles(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		fuel = math.random(70,80)
		setElementData(v, "fuel", fuel)
	end
end

function processFuel(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		if not BlockedModel[getElementModel ( v )] then 
			local fuel = getElementData(v, "fuel") or math.random(70,80)
			if (getVehicleEngineState(v) and fuel > 0 ) then
				fuel = fuel - factor
			end
			if (fuel <= 0.99) then
				fuel = 0
				setVehicleEngineState(v, false)
				
			end
			setElementData(v, "fuel", fuel)
		end
	end
end

createVehicles()
setTimer(processFuel, 1000, 0)

 

Thank you my friend

5 hours ago, Simple. said:

server/main.Lua

 


factor = 0.03
local BlockedModel = {
	-- [Car id] = true,
	  [411] = true,
	  [457] = true,
  }

function createVehicles(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		fuel = math.random(70,80)
		setElementData(v, "fuel", fuel)
	end
end

function processFuel(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		if not BlockedModel[getElementModel ( v )] then 
			local fuel = getElementData(v, "fuel") or math.random(70,80)
			if (getVehicleEngineState(v) and fuel > 0 ) then
				fuel = fuel - factor
			end
			if (fuel <= 0.99) then
				fuel = 0
				setVehicleEngineState(v, false)
				
			end
			setElementData(v, "fuel", fuel)
		end
	end
end

createVehicles()
setTimer(processFuel, 1000, 0)

 

Thank you my friend

 

19 hours ago, The_GTA said:

I suggest that you tell the client whenever he enters a vehicle whether it is a job car or not from serverside. Then you start drawing the HUD after you received that server event. Your script seems pretty big but it should not be too hard.

This time Simple solved my problem, but thank you dude. I remember you from a week ago hahaha

 

5 hours ago, Simple. said:

server/main.Lua

 


factor = 0.03
local BlockedModel = {
	-- [Car id] = true,
	  [411] = true,
	  [457] = true,
  }

function createVehicles(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		fuel = math.random(70,80)
		setElementData(v, "fuel", fuel)
	end
end

function processFuel(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		if not BlockedModel[getElementModel ( v )] then 
			local fuel = getElementData(v, "fuel") or math.random(70,80)
			if (getVehicleEngineState(v) and fuel > 0 ) then
				fuel = fuel - factor
			end
			if (fuel <= 0.99) then
				fuel = 0
				setVehicleEngineState(v, false)
				
			end
			setElementData(v, "fuel", fuel)
		end
	end
end

createVehicles()
setTimer(processFuel, 1000, 0)

 

Thank you my friend

 

19 hours ago, The_GTA said:

I suggest that you tell the client whenever he enters a vehicle whether it is a job car or not from serverside. Then you start drawing the HUD after you received that server event. Your script seems pretty big but it should not be too hard.

This time Simple solved my problem, but thank you dude. I remember you from a week ago hahaha

 

Link to comment

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...