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

Wysłany: 2016-03-05, 12:18


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

M?j System Aut: System Aut By Pan Prezes
SetElementData: pojazd_przebieg
Problem: Nie Liczy Si? Przebieg Ca?y Czas Jest 0


Kod:

--[[
Author: AteX<atexprogramming@gmail.com>
]]--

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

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 paliwo = getElementData(v,"paliwo") or 0
local przebieg = getElementData(v,"pojazd_przebieg") 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", paliwo+20, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText(przebieg.."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 paliwo < 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
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)

--[[
Author: AteX<atexprogramming@gmail.com>


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:22


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4261 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

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

Ostrzeżeń: 40%
Mo?e dlatego ?e nie naliczasz przebiegu ? lub nie nadajesz elementDaty "pojazd_przebieg" i dlatego wy?wietla si? 0

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:23


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

a jak to zrobi??

[ Dodano: 2016-03-05, 12:25 ]
ale mam nadan?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:27


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4261 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

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

Ostrzeżeń: 40%
Podaje tobie kod na naliczanie przebiegu , dodajesz to do kodu z licznikiem
local lu=getTickCount()

local function naliczPrzebieg(veh)
    if (getTickCount()-lu>250then
    local przebieg=getElementData(veh,"pojazd_przebieg") or 0
    lu=getTickCount()
    local vx,vy,vz=getElementVelocity(veh)
    local spd=((vx^vy^vz^2)^(0.5)/100)
    if (spd>0then
        przebieg=przebieg+(spd*2)
        setElementData(veh"pojazd_przebieg"przebieg)
    end
    end
end

function updatePrzebieg()
    local v=getPedOccupiedVehicle(localPlayer)
    if (not vthen return end
    if (not getVehicleEngineState(v)) then return end
    if (getVehicleController(v)~=localPlayerthen return end
    naliczPrzebieg(v)
end

addEventHandler("onClientRender"rootupdatePrzebieg)


P.S Kod nie jest m?j , autorem jest PanPrezes.

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:33


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

nadal 0

[ Dodano: 2016-03-05, 12:37 ]
ok dzia?a ale mam tak
http://scr.hu/9vti/toduv
ale chem zeby by?o np tak 0.1 albo 88.5
88-km 5-setki metr?w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:37


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4261 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

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

Ostrzeżeń: 40%
Sprawd? czy poda?em dobre elementDaty (mo?e si? gdzie? machn??em) i poje?dzij troch? ?eby sprawdzi? czy nabija przebieg.

Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:45


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

ok dzia?a ale mam tak
http://scr.hu/9vti/toduv
ale chem zeby by?o np tak 0.1 albo 88.5
88-km 5-setki metr?w

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:53


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4261 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

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

Ostrzeżeń: 40%
Powinno lata? ^^
dxDrawText(('%.1f'):format(przebieg)"km"0.91610.91940.95420.9352tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:56


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

nie dzia?a pokazuje si? to http://scr.hu/9vti/rz7vs

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 12:58


_Wicek_

Majstersztyk






Wiek: 25
Na forum: 4261 dni
Posty: 747
Nick w MP: Wicek

Piwa: 1841

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

Ostrzeżeń: 40%
Jest co? w DB ?

[ Dodano: 2016-03-05, 13:01 ]
Ehhh... , m?j b??d , teraz b?dzie lata? ^^

dxDrawText(('%.1f'):format(przebieg).."km"0.91610.91940.95420.9352tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)


Podpis

Support-Team: 25.01.2016
Moderator: 10.07.2016




GG: 51274621
Skype : kuba_wicinski
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 13:07


mati2409

Uczę się LUA!






Wiek: 33
Na forum: 3800 dni
Posty: 97
Nick w MP: mati2409

Piwa: 73

Respekt: 50

Wicek7, Nie m?j temat ,ale da si? zwolni? to naliczenie przebiegu ? ,bo jad?c do ls z sf mam okolo 50km przeb lub wi?cej

Podpis
Mapping <3
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 13:08


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

ok jest ju? ok

[ Dodano: 2016-03-05, 13:14 ]
Mam kolejny problem niema kontrolek ss http://scr.hu/9vti/v0f6u

Kod:

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

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 paliwo = getElementData(v,"fuel") or 0
local przebieg = getElementData(v,"pojazd_przebieg") 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", paliwo+20, 0, 0, tocolor(255, 255, 255, 255), false)
dxDrawText(('%.1f'):format(przebieg).."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 paliwo < 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
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)

--[[
Author: AteX<atexprogramming@gmail.com>



Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 13:16


mati2409

Uczę się LUA!






Wiek: 33
Na forum: 3800 dni
Posty: 97
Nick w MP: mati2409

Piwa: 73

Respekt: 50

Aidis, Poniewa? tam nadal jest zmienna v musisz dopisa? po prostu veh

Podpis
Mapping <3
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 13:18


P.Wiśnia

Programista LUA






Wiek: 24
Na forum: 4045 dni
Posty: 568
Nick w MP: P.Wiśnia

Piwa: 376

Respekt: 100
Respekt: 100

o dzienki

[ Dodano: 2016-03-05, 13:20 ]
ale mam kolejny problem tera? paliwo mam na 0 poprostu sie nie wyswietla

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-03-05, 13:22


mati2409

Uczę się LUA!






Wiek: 33
Na forum: 3800 dni
Posty: 97
Nick w MP: mati2409

Piwa: 73

Respekt: 50

w paliwie masz tak samo najlepiej skopiuj to co ja tu mam
 --[[
    AuthorAteX<atexprogramming@gmail.com>
]]--

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

function hud()
    local veh getPedOccupiedVehicle(localPlayer)
    if veh then
        local sx,sy,sz getElementVelocity(getPedOccupiedVehicle(localPlayer))
        local kmhs math.ceil(((sx^2+sy^2+sz^2)^(0.5))*155)
        local paliwo getElementData(veh,"pojazd_paliwo") or 0
        local przebieg getElementData(veh,"pojazd_przebieg") or 0
        
        -- ogolne
        dxDrawImage(0.81770.76850.18230.2315"images/spdmeter1.png"000tocolor(255255255255), false)
        dxDrawImage(0.86250.82310.14480.1296"images/wskaznik.png"kmhs+32000tocolor(255255255255), false)
        dxDrawImage(0.82500.93240.05100.0454"images/wskaznik.png"paliwo+3000tocolor(255255255255), false)
        dxDrawText(('%.1f'):format(przebieg).."km"0.91610.91940.95420.9352tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
        
        -- kontrolki
        if paliwo 30 then
            r1,g1,b1 254,107,3
        else
            r1,g1,b1 255,255,255
        end
        
        if isElementFrozen(vehthen
            r2,g2,b2 255,0,0
        else
            r2,g2,b2 255,255,255
        end
        
        local silnik getVehicleEngineState(veh)
        if silnik == false then
            r3,g3,b3 255,0,0
        else
            r3,g3,b3 255,255,255
        end
        
        if getVehicleOverrideLights(veh) ~= 2 then
            r4,g4,b4 255,255,255
        else
            r4,g4,b4 70,184,73
        end
        
        dxDrawImage(0.84320.96300.01560.0278"images/paliwo.png"000tocolor(r1g1b1200), false)
        dxDrawImage(0.92660.96300.01560.0278"images/reczny.png"000tocolor(r2g2b2200), false)
        dxDrawImage(0.90570.95370.01560.0278"images/silnik.png"000tocolor(r3g3b3200), false)
        dxDrawImage(0.94740.95370.01560.0278"images/swiatla.png"000tocolor(r4g4b4200), false)
    end
end

addEventHandler("onClientVehicleEnter",root,function(plr)
    if plr ~= localPlayer then return end
    local veh getPedOccupiedVehicle(localPlayer)
    if rowery[getElementModel(v)] 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 lu=getTickCount()

local function naliczPrzebieg(veh)
    if (getTickCount()-lu>250then
    local przebieg=getElementData(veh,"pojazd_przebieg") or 0
    lu=getTickCount()
    local vx,vy,vz=getElementVelocity(veh)
    local spd=((vx^vy^vz^2)^(0.5)/100)
    if (spd>0then
        przebieg=przebieg+(spd*2)
        setElementData(veh"pojazd_przebieg"przebieg)
    end
    end
end

function updatePrzebieg()
    local veh=getPedOccupiedVehicle(localPlayer)
    if (not vehthen return end
    if (not getVehicleEngineState(veh)) then return end
    if (getVehicleController(veh)~=localPlayerthen return end
    naliczPrzebieg(veh)
end

addEventHandler("onClientRender"rootupdatePrzebieg)
--[[
    AuthorAteX<atexprogramming@gmail.com>
]]--

PS: Jak nie chcesz kopiowa? tego co da?em tam gdzie jest samo v wpisz veh i dzia?a prawid?owo :P Liczne na :piwo:

Podpis
Mapping <3
Postaw piwo autorowi tego posta
 

 
Tagi: przebieg :: liczniku :: nie :: działa
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA 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