local czas = getTickCount()
isBike = {
[509]=true, --Bike
[481]=true, --BMX
[510]=true, --Mountain bike
[405]=true, --santiniel
[431]=true, --busik
[437]=true, --busiczek
[524]=true, --betonek
}
function odejmijPaliwo(pojazd)
if getTickCount() - czas > 150 then
czas = getTickCount()
local paliwo = getElementData(pojazd, "pojazd_paliwo") or 0
local vx,vy,vz = getElementVelocity(pojazd)
local spd = ((vx^2+vy^2+vz^2)^(0.5)/150)
if spd > 0 then
paliwo = paliwo-spd*2
setElementData(pojazd, "pojazd_paliwo", paliwo)
end
end
end
addEventHandler("onClientRender", root, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if isBike[getElementModel(pojazd)] then return end
if not getVehicleEngineState(pojazd) then return end
if getVehicleController(pojazd) ~= localPlayer then return end
odejmijPaliwo(pojazd)
end)
function zgasSilnik()
for i,v in ipairs(getElementsByType("vehicle")) do
local data = getElementData(v, "pojazd_paliwo")
if data then
if tonumber(data) < 0 then
setVehicleEngineState(v, false)
end
end
end
end
setTimer(zgasSilnik, 1000, 999999999)