Witam zrobi?em dzisiaj baz? stra?y po?arnej i postawi?em przez map editora tam auta. I je?eli wchodz? do ranchera stra?ackiego to licznik mi si? nie pojawia ani nie mog? jecha? Prosz? o pomoc.
Ostatnio zmieniony przez GamerHD11 2015-06-24, 22:57, w całości zmieniany 1 raz
Postaw je kodem, cho? to niewiele zmieni... Poza tym, daj kod licznika je?eli mo?esz, bo nie widz?, tutaj ?adnego b??du : /
Podpis
Jedyny kontakt ze mną to PW forum
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
local x,y = guiGetScreenSize()
pojazdy = {
[509]=true,
[481]=true,
[510]=true,
}
local czas = getTickCount()
local czas2 = getTickCount()
function naliczprzebieg(pojazd)
if getTickCount() - czas > 150 then
czas = getTickCount()
local przebieg = getElementData(pojazd, "przebieg") or 0
local vx,vy,vz = getElementVelocity(pojazd)
local speed = ((vx^2+vy^2+vz^2)^ (0.5)/100)
if speed > 0 then
przebieg = przebieg+speed*2
setElementData(pojazd, "przebieg", przebieg)
end
end
end
addEventHandler("onClientRender", root, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if pojazdy[getElementModel(pojazd) ] then return end
if not getVehicleEngineState(pojazd) then return end
if getVehicleController(pojazd) ~= localPlayer then return end
naliczprzebieg(pojazd)
end
end)
function naliczpaliwo(pojazd)
if getTickCount() - czas2 > 100 then
czas2 = getTickCount()
local paliwo = getElementData(pojazd, "fuel") or 0
local sx,sy,sz = getElementVelocity(pojazd)
local speed = ((sx^2+sy^2+sz^2)^ (0.5)/100)
if speed > 0 then
paliwo = paliwo-speed
setElementData(pojazd, "fuel", paliwo)
end
end
end
function koniecpaliwa()
veh = getPedOccupiedVehicle(localPlayer)
if veh and (not getElementData(veh,"fuel") == false ) and getElementData(veh,"fuel") <= 0 then
setElementData(veh,"fuel",0)
setElementData(veh,"koniecpaliwa",true)
setVehicleEngineState(veh,false)
end
end
addEventHandler("onClientRender",root,koniecpaliwa)
addEventHandler("onClientRender", root, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if pojazdy[getElementModel(pojazd) ] then return end
if not getVehicleEngineState(pojazd) then return end
if getVehicleController(pojazd) ~= localPlayer then return end
naliczpaliwo(pojazd)
end)
function licznik ()
local veh=getPedOccupiedVehicle(localPlayer)
if (veh) then
if isPedInVehicle (localPlayer) == false then return end
local sx, sy, sz = getElementVelocity(getPedOccupiedVehicle(localPlayer))
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5)) * 161)
local przebieg = math.floor(getElementData(veh, "przebieg"))
local paliwo = math.floor(getElementData(veh, "fuel"))
local model = getVehicleName(veh)
dxDrawText(" "..kmhs.." KM/H ", x/1.29, y/1.55, 1302, 801, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawText("Przebieg: "..przebieg.." KM ", x/1.29, y/1.48, 1163, 801, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawText("Paliwo: "..paliwo.." L ", x/1.29, y/1.41, 1209, 835, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawText("Model: "..model.." ", x/1.29, y/1.34, 1209, 835, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawRectangle(924, 636, x/4.5, y/6, tocolor(47, 47, 251, 50), false)
end
end
addEventHandler("onClientRender", getRootElement(), licznik)
local x,y = guiGetScreenSize()
pojazdy = {
[509]=true,
[481]=true,
[510]=true,
}
local czas = getTickCount()
local czas2 = getTickCount()
function naliczprzebieg(pojazd)
if getTickCount() - czas > 150 then
czas = getTickCount()
local przebieg = getElementData(pojazd, "przebieg") or 0
local vx,vy,vz = getElementVelocity(pojazd)
local speed = ((vx^2+vy^2+vz^2)^ (0.5)/100)
if speed > 0 then
przebieg = przebieg+speed*2
setElementData(pojazd, "przebieg", przebieg)
end
end
end
addEventHandler("onClientRender", root, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if pojazdy[getElementModel(pojazd) ] then return end
if not getVehicleEngineState(pojazd) then return end
if getVehicleController(pojazd) ~= localPlayer then return end
naliczprzebieg(pojazd)
end
end)
function naliczpaliwo(pojazd)
if getTickCount() - czas2 > 100 then
czas2 = getTickCount()
local paliwo = getElementData(pojazd, "fuel") or 0
local sx,sy,sz = getElementVelocity(pojazd)
local speed = ((sx^2+sy^2+sz^2)^ (0.5)/100)
if speed > 0 then
paliwo = paliwo-speed
setElementData(pojazd, "fuel", paliwo)
end
end
end
function koniecpaliwa()
veh = getPedOccupiedVehicle(localPlayer)
if veh and (not getElementData(veh,"fuel") == false ) and getElementData(veh,"fuel") <= 0 then
setElementData(veh,"fuel",0)
setElementData(veh,"koniecpaliwa",true)
setVehicleEngineState(veh,false)
end
end
addEventHandler("onClientRender",root,koniecpaliwa)
addEventHandler("onClientRender", root, function()
local pojazd = getPedOccupiedVehicle(localPlayer)
if not pojazd then return end
if pojazdy[getElementModel(pojazd) ] then return end
if not getVehicleEngineState(pojazd) then return end
if getVehicleController(pojazd) ~= localPlayer then return end
naliczpaliwo(pojazd)
end)
function licznik ()
local veh=getPedOccupiedVehicle(localPlayer)
if (veh) then
if isPedInVehicle (localPlayer) == false then return end
local sx, sy, sz = getElementVelocity(getPedOccupiedVehicle(localPlayer))
local kmhs = math.ceil(((sx^2+sy^2+sz^2)^(0.5)) * 161)
local przebieg = math.floor(getElementData(veh, "przebieg"))
local paliwo = math.floor(getElementData(veh, "fuel"))
local model = getVehicleName(veh)
dxDrawText(" "..kmhs.." KM/H ", x/1.29, y/1.55, 1302, 801, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawText("Przebieg: "..przebieg.." KM ", x/1.29, y/1.48, 1163, 801, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawText("Paliwo: "..paliwo.." L ", x/1.29, y/1.41, 1209, 835, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawText("Model: "..model.." ", x/1.29, y/1.34, 1209, 835, tocolor(3, 190, 251, 255), 1.00, "pricedown", "left", "top", false, false, false, false, false)
dxDrawRectangle(924, 636, x/4.5, y/6, tocolor(47, 47, 251, 50), false)
end
end
addEventHandler("onClientRender", root, licznik)
Sprawdz teraz
Podpis
Jedyny kontakt ze mną to PW forum
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
Teraz sie nie wy?wietla w ?adnym poje?dzie, a wcze?niej wy?wieta? si? tylko w innych autach ni? tych stworzonych przez map editora ( auta z freeroam, panel admina itp. )
Lecz auta mog? je?dzi?.
[ Dodano: 2015-06-24, 23:13 ]
Licznik si? ju? pokazuje i jest dobrze, ale co z tymi rancherami stworzonymi przez map editora, pisze ?e maj? 0 paliwa i nwm gdzie mam zrobi? setElementDate czy co? ?eby te paliwo ustawi? ? Pami?tam mia?em kiedy? taki skrypt na paliwo to w pliku z map? dodawa?a si? kolumna fuel="ilosc". Nawet mam do niego link.
Usun?? pojazdy z map editora, wszed? na wiki.multitheftauto.com, zczai? ID rancher?w, stworzy? nowy plik np. server.lua.
W pliku server.lua stworzy? tyle pojazd?w ile chcesz za pomoc? funkcji createVehicle i p?tli, i potem zrobi? to co Ci loop poda? :
for k,v in ipairs(getElementsByType("vehicle", resourceRoot)) do
setElementData(v, "paliwo", 50
end
Podpis
Jedyny kontakt ze mną to PW forum
local noobs = getElementsByTitle("player", "Programista LUA")
for k, v in ipairs(noobs) do
outputChatBox("Bez mózgu jest użytkownik o nicku: "..getPlayerName(v), root)
destroyElement(v)
end
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