Jump to content

[DUVIDA]Sobre gasolina


Recommended Posts

Tenho um script aqui de gasolina, só ele a bicicleta ta com gasolina, como faço para colocar, para não reconhecer tais veiculos?

Qual função eu posso usar?

 

factor = 0.03

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

function processFuel(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		local fuel = getElementData(v, "fuel") or math.random(10,25)
		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

createVehicles()
setTimer(processFuel, 1000, 0)

 

Link to comment
  • Other Languages Moderators
factor = 0.03

function createVehicles(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		if getVehicleType (v) ~= "BMX" then
			fuel = math.random(10,25)
			setElementData(v, "fuel", fuel)
		end
	end
end

function processFuel(player)
	for i,v in ipairs(getElementsByType("vehicle")) do
		if getVehicleType (v) ~= "BMX" then
			local fuel = getElementData(v, "fuel") or math.random(10,25)
			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)

 

Colocando a verificação do tipo de veículo. Onde só funciona se o tipo for diferente de "BMX" (bicicleta)

  • Thanks 1
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...