fuelTimers = { }
function aFuel ( )
if ( not getElementData ( source, "fuel" ) ) then
setElementData ( source, "fuel", 25 )
end
end
function dropFuel ( player, seat, jacked )
if getElementData ( source, "fuel" ) then
if getVehicleController ( source ) then
if ( getVehicleEngineState ( source ) == true ) then
fuelTimers [ source ] = setTimer (
function ( vehiclex )
if getVehicleController ( vehiclex ) then
if ( getVehicleEngineState ( vehiclex ) == true ) then
if ( getElementData ( vehiclex, "fuel" ) ~= 0 ) then
setElementData ( vehiclex, "fuel", getElementData ( vehiclex, "fuel" ) - 1 )
end
end
end
end
,1000, 0, source
)
end
end
end
end
function killFuelTimer ( _, seat )
if ( seat == 0 ) then
if isTimer ( fuelTimers [ source ] ) then
killTimer ( fuelTimers [ source ] )
end
end
end
addEventHandler ( "onVehicleExit", getRootElement(), killFuelTimer )
function testFuel ( playerSource )
if isPedInVehicle ( playerSource ) then
local vehicle = getPedOccupiedVehicle ( playerSource )
if ( getVehicleController ( vehicle ) == playerSource ) then
if getElementData ( vehicle, "fuel" ) then
if ( getElementData ( vehicle, "fuel" ) == 0 ) then
setVehicleEngineState ( vehicle, false )
outputChatBox ( "Nie masz paliwa w samochodzie", playerSource )
else
outputChatBox ( "Masz paliwo w samochodzie", playerSource )
end
else
outputChatBox ( "Ten pojazd nie ma paliwa w sobie", playerSource )
end
end
end
end
addCommandHandler ( "tf", testFuel )
addEventHandler ( "onVehicleStartEnter", getRootElement(), aFuel )
addEventHandler ( "onVehicleEnter", getRootElement(), dropFuel )