Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2016-04-28, 17:30


amama5







Wiek: 39
Na forum: 4886 dni
Posty: 57
Nick w MP: kamiloooswas

Piwa: 2

Respekt: 40,5

Ostrzeżeń: 100%
Witam mam problem przebiegiem by atex, ot?? pozamiania?em wszystkie elementdaty pod m?j system i wywala mi takie co?.... http://imgur.com/FjuMMeo Jak naprawi? ?eby przebieg ograniczy? si? do : np. 11.5km?

Kod :

local w,h = guiGetScreenSize()
local rowery = {[509]=true,[481]=true,[510]=true,}

function math.round(number, decimals, method)
    decimals = decimals or 0
    local factor = 10 ^ decimals
    if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
    else return tonumber(("%."..decimals.."f"):format(number)) end
end

function hud()
    local v = getPedOccupiedVehicle(localPlayer)
    if v then
        local sx,sy,sz = getElementVelocity(getPedOccupiedVehicle(localPlayer))
        local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
        local fuel=getElementData(v,"vehicle:fuel") or 0
        local mileage=getElementData(v,"vehicle:mileage") or 0
        
        -- ogolne
        dxDrawImage(w * 0.8177, h * 0.7685, w * 0.1823, h * 0.2315, "images/spdmeter1.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(w * 0.8625, h * 0.8231, w * 0.1448, h * 0.1296, "images/wskaznik.png", kmhs+320, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawImage(w * 0.8250, h * 0.9324, w * 0.0510, h * 0.0454, "images/wskaznik.png", fuel+30, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText(mileage.."km", w * 0.9161, h * 0.9194, w * 0.9542, h * 0.9352, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)
        
        -- kontrolki
        if fuel < 30 then
            r1,g1,b1 = 254,107,3
        else
            r1,g1,b1 = 255,255,255
        end
        
        if isElementFrozen(v) then
            r2,g2,b2 = 255,0,0
        else
            r2,g2,b2 = 255,255,255
        end
        
        local silnik = getVehicleEngineState(v)
        if silnik == false then
            r3,g3,b3 = 255,0,0
        else
            r3,g3,b3 = 255,255,255
        end
        
        if getVehicleOverrideLights(v) ~= 2 then
            r4,g4,b4 = 255,255,255
        else
            r4,g4,b4 = 70,184,73
        end
        
        dxDrawImage(w * 0.8432, h * 0.9630, w * 0.0156, h * 0.0278, "images/paliwo.png", 0, 0, 0, tocolor(r1, g1, b1, 200), false)
        dxDrawImage(w * 0.9266, h * 0.9630, w * 0.0156, h * 0.0278, "images/reczny.png", 0, 0, 0, tocolor(r2, g2, b2, 200), false)
        dxDrawImage(w * 0.9057, h * 0.9537, w * 0.0156, h * 0.0278, "images/silnik.png", 0, 0, 0, tocolor(r3, g3, b3, 200), false)
        dxDrawImage(w * 0.9474, h * 0.9537, w * 0.0156, h * 0.0278, "images/swiatla.png", 0, 0, 0, tocolor(r4, g4, b4, 200), false)
    end
end

addEventHandler("onClientVehicleEnter",root,function(plr)
    if plr ~= localPlayer then return end
    local v = getPedOccupiedVehicle(localPlayer)
    if rowery[getElementModel(v)] then return end
    if getElementData(v,"dokupienia") then return end
    addEventHandler("onClientRender",root,hud)
end)

addEventHandler("onClientVehicleExit",root,function(plr,seat)
    if plr ~= localPlayer then return end
    if seat ~= 0 then return end
    removeEventHandler("onClientRender",root,hud)
end)

local czas = getTickCount()

isBike = {
    [509]=true, --Bike
    [481]=true, --BMX
    [510]=true, --Mountain bike
    
}

function odejmijfuel(pojazd)
    if getTickCount() - czas > 150 then
        czas = getTickCount()
        local fuel=getElementData(pojazd,"vehicle:fuel") or 0
        local vx,vy,vz = getElementVelocity(pojazd)
        local spd = ((vx^2+vy^2+vz^2)^(0.5)/150)
        if spd > 0 then
            fuel = fuel-spd*2
        local fuel=getElementData(pojazd,"vehicle:fuel") or 0
        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
    odejmijfuel(pojazd)
end)

function zgasSilnik()
    for i,v in ipairs(getElementsByType("vehicle")) do
        local fuel=getElementData(v,"vehicle:fuel") or 0
        if data then
        if tonumber(data) <= 0 then
            setVehicleEngineState(v, false)
        end
end
    end
end
setTimer(zgasSilnik, 1000, 0) 

local czas = getTickCount()

isBike = {
    [509]=true, --Bike
    [481]=true, --BMX
    [510]=true, --Mountain bike
}

function naliczmileage(pojazd)
    if getTickCount() - czas > 300 then
        czas = getTickCount()
        local mileage=getElementData(pojazd,"vehicle:mileage") or 0
        local vx,vy,vz = getElementVelocity(pojazd)
        local spd = ((vx^2+vy^2+vz^2)^(0.5)/100)
        if spd > 0 then
            mileage = mileage+spd*2
            setElementData(pojazd, "vehicle:mileage", mileage)
        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
    naliczmileage(pojazd)
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-04-28, 21:37


_Wicek_

Majstersztyk






Wiek: 26
Na forum: 4401 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1842

Respekt: 360,5
Respekt: 360,5Respekt: 360,5Respekt: 360,5Respekt: 360,5

Ostrzeżeń: 40%
        dxDrawText(math.floor(mileage).."km", w * 0.9161, h * 0.9194, w * 0.9542, h * 0.9352, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false)


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Tagi: przebieg :: atex
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Przebieg by AteX Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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
Dodaj temat do Ulubionych
Wersja do druku