Witam, posiadam system prywatnych pojazd?w od PanaPrezesa (nieco przerobiony przeze mnie), do tego system licznika wy?wietlaj?cy ID i przebieg. Z ID jest wszystko dobrze, s?k w tym, ?e przebieg ca?y czas wskazuje 0. Jakie? pomys?y?
local czas = getTickCount()
isBike = {
[509]=true, --Bike
[481]=true, --BMX
[510]=true, --Mountain bike
}
function naliczPrzebieg(pojazd)
if getTickCount() - czas > 300 then
czas = getTickCount()
local przebieg = getElementData(pojazd, "pojazd_przebieg") or 0
local vx,vy,vz = getElementVelocity(pojazd)
local spd = ((vx^2+vy^2+vz^2)^(0.5)/100)
if spd > 0 then
przebieg = przebieg+spd*2
setElementData(pojazd, "pojazd_przebieg", przebieg)
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
naliczPrzebieg(pojazd)
end)
sw,sh = guiGetScreenSize()
isBike = {
[509]=true, --Bike
[481]=true, --BMX
[510]=true, --Mountain bike
}
addEventHandler("onClientRender", root, function()
if isPlayerMapVisible() then return end
local pojazd = getPedOccupiedVehicle(localPlayer)
if pojazd then
if isBike[getElementModel(pojazd)] then return end
local sprawdzpaliwo = tonumber(getElementData(pojazd, "pojazdy_paliwo"))
local sprawdzprzebieg = tonumber(getElementData(pojazd, "pojazd_przebieg")) or 000
local id = getElementData(pojazd, "car_id") or " -"
local przebieg = math.floor(sprawdzprzebieg) or 0
if #tostring(przebieg) == 1 then przebieg = "0000"..przebieg
elseif #tostring(przebieg) == 2 then przebieg = "000"..przebieg
elseif #tostring(przebieg) == 3 then przebieg = "00"..przebieg
elseif #tostring(przebieg) == 4 then przebieg = "0"..przebieg
elseif #tostring(przebieg) == 5 then przebieg = ""..przebieg
elseif #tostring(przebieg) == 8 then przebieg = przebieg end
local sx, sy, sz = getElementVelocity(pojazd)
local predkosc = math.ceil(((sx^2+sy^2+sz^2)^(0.5)) * 161)
--...
--gui
--...
dxDrawText(""..przebieg.." KM", 1300/1440*sw, 940/900*sh, 1424/1440*sw, 802/900*sh, tocolor(255, 120, 0, 255), 0.80, "pricedown", "center", "center", false, false, false, false, false)
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach