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
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>
Wysłany: 2016-03-05, 12:22
_Wicek_
Majstersztyk
Wiek: 25 Na forum: 4261 dni Posty: 747
Nick w MP: Wicek
Piwa : 1841
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
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
a jak to zrobi??
[ Dodano : 2016-03-05, 12:25 ]
ale mam nadan?
Wysłany: 2016-03-05, 12:27
_Wicek_
Majstersztyk
Wiek: 25 Na forum: 4261 dni Posty: 747
Nick w MP: Wicek
Piwa : 1841
Podaje tobie kod na naliczanie przebiegu , dodajesz to do kodu z licznikiem
local lu = getTickCount ()
local function naliczPrzebieg ( veh )
if ( getTickCount ()- lu > 250 ) then
local przebieg = getElementData ( veh , "pojazd_przebieg" ) or 0
lu = getTickCount ()
local vx , vy , vz = getElementVelocity ( veh )
local spd =(( vx ^ 2 + vy ^ 2 + vz ^ 2 )^( 0.5 )/ 100 )
if ( spd > 0 ) then
przebieg = przebieg +( spd * 2 )
setElementData ( veh , "pojazd_przebieg" , przebieg )
end
end
end
function updatePrzebieg ()
local v = getPedOccupiedVehicle ( localPlayer )
if ( not v ) then return end
if ( not getVehicleEngineState ( v )) then return end
if ( getVehicleController ( v )~= localPlayer ) then return end
naliczPrzebieg ( v )
end
addEventHandler ( "onClientRender" , root , updatePrzebieg )
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
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
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
Wysłany: 2016-03-05, 12:37
_Wicek_
Majstersztyk
Wiek: 25 Na forum: 4261 dni Posty: 747
Nick w MP: Wicek
Piwa : 1841
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
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
Wysłany: 2016-03-05, 12:53
_Wicek_
Majstersztyk
Wiek: 25 Na forum: 4261 dni Posty: 747
Nick w MP: Wicek
Piwa : 1841
Powinno lata? ^^
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 )
Podpis
Support-Team: 25.01.2016
Moderator: 10.07.2016
GG: 51274621
Skype : kuba_wicinski
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
Wysłany: 2016-03-05, 12:58
_Wicek_
Majstersztyk
Wiek: 25 Na forum: 4261 dni Posty: 747
Nick w MP: Wicek
Piwa : 1841
Jest co? w DB ?
[ Dodano : 2016-03-05, 13:01 ]
Ehhh... , m?j b??d , teraz b?dzie lata? ^^
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 )
Podpis
Support-Team: 25.01.2016
Moderator: 10.07.2016
GG: 51274621
Skype : kuba_wicinski
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
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
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
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>
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
Aidis , Poniewa? tam nadal jest zmienna v musisz dopisa? po prostu veh
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
o dzienki
[ Dodano : 2016-03-05, 13:20 ]
ale mam kolejny problem tera? paliwo mam na 0 poprostu sie nie wyswietla
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
w paliwie masz tak samo najlepiej skopiuj to co ja tu mam --[[
Author : AteX < atexprogramming @ gmail . com >
]]--
local w , h = 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 ( 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 + 30 , 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 ( veh ) then
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 ( 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 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 > 250 ) then
local przebieg = getElementData ( veh , "pojazd_przebieg" ) or 0
lu = getTickCount ()
local vx , vy , vz = getElementVelocity ( veh )
local spd =(( vx ^ 2 + vy ^ 2 + vz ^ 2 )^( 0.5 )/ 100 )
if ( spd > 0 ) then
przebieg = przebieg +( spd * 2 )
setElementData ( veh , "pojazd_przebieg" , przebieg )
end
end
end
function updatePrzebieg ()
local veh = getPedOccupiedVehicle ( localPlayer )
if ( not veh ) then return end
if ( not getVehicleEngineState ( veh )) then return end
if ( getVehicleController ( veh )~= localPlayer ) then return end
naliczPrzebieg ( veh )
end
addEventHandler ( "onClientRender" , root , updatePrzebieg )
--[[
Author : AteX < atexprogramming @ gmail . com >
]]--
PS: Jak nie chcesz kopiowa? tego co da?em tam gdzie jest samo v wpisz veh i dzia?a prawid?owo Liczne na
Tagi: przebieg :: liczniku :: nie :: działa
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: