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

Wysłany: 2015-06-24, 22:25


GamerHD11







Wiek: 24
Na forum: 4260 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

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.

addEventHandler("onClientRender"root, function()
    local pojazd getPedOccupiedVehicle(localPlayer)
    if not pojazd then return end
    if pojazdy[getElementModel(pojazd) ] then return end
    if not getVehicleEngineState(pojazdthen return end
    if getVehicleController(pojazd) ~= localPlayer then return end
    naliczpaliwo(pojazd)
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


Ostatnio zmieniony przez GamerHD11 2015-06-24, 22:57, w całości zmieniany 1 raz  
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 22:28


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

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

Kod:


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
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 22:44


GamerHD11







Wiek: 24
Na forum: 4260 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

local x,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(pojazdthen 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(pojazdthen return end
    if getVehicleController(pojazd) ~= localPlayer then return end
    naliczpaliwo(pojazd)
end)

function licznik ()
    local veh=getPedOccupiedVehicle(localPlayer)
    if (vehthen
    if isPedInVehicle (localPlayer) == false then return end
    local sxsysz 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.29y/1.551302801tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawText("Przebieg: "..przebieg.." KM "x/1.29y/1.481163801tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawText("Paliwo: "..paliwo.." L "x/1.29y/1.411209835tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawText("Model: "..model.." "x/1.29y/1.341209835tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawRectangle(924636x/4.5y/6tocolor(474725150), false)
    end
    end
addEventHandler("onClientRender"getRootElement(), licznik)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 22:47


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3


local x,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(pojazdthen 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(pojazdthen return end
    if getVehicleController(pojazd) ~= localPlayer then return end
    naliczpaliwo(pojazd)
end)

function licznik ()
    local veh=getPedOccupiedVehicle(localPlayer)
    if (vehthen
    if isPedInVehicle (localPlayer) == false then return end
    local sxsysz 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.29y/1.551302801tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawText("Przebieg: "..przebieg.." KM "x/1.29y/1.481163801tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawText("Paliwo: "..paliwo.." L "x/1.29y/1.411209835tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawText("Model: "..model.." "x/1.29y/1.341209835tocolor(3190251255), 1.00"pricedown""left""top"falsefalsefalsefalsefalse)
        dxDrawRectangle(924636x/4.5y/6tocolor(474725150), false)
    end
    end
addEventHandler("onClientRender"rootlicznik)



Sprawdz teraz

Podpis
Jedyny kontakt ze mną to PW forum

Kod:


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
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 22:53


GamerHD11







Wiek: 24
Na forum: 4260 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

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.

LINK: https://community.multitheftauto.com/index.php?p=resources&s=details&id=9166

Ale nie wiem co mam z niego skopiowa?, ?eby robi?o sie tak ponownie :(

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 23:21


Loop

Inspektor






Wiek: 27
Na forum: 4289 dni
Posty: 311
Nick w MP: Inspektor

Piwa: 201

Respekt: 130
Respekt: 130

Mozesz pobrac wszystkie pojazdy z skryptu i dac im elementDate paliwa.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 23:23


GamerHD11







Wiek: 24
Na forum: 4260 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

if getElementType(source) ~= 'vehicle' then return end
tak ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-24, 23:34


Loop

Inspektor






Wiek: 27
Na forum: 4289 dni
Posty: 311
Nick w MP: Inspektor

Piwa: 201

Respekt: 130
Respekt: 130


for i,v in ipairs(getElementsByType("vehicle"resourceRoot)) do
setElementData(v"fuel"30)
end
o tak

Tylko musisz to wsadzic do tej mapy i dopisac do mety.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-25, 12:52


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

Respekt: 955,3
Respekt: 955,3Respekt: 955,3

Najlepiej by?oby jakby? zrobi? tak :

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

Kod:


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
Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-06-25, 15:23


GamerHD11







Wiek: 24
Na forum: 4260 dni
Posty: 259
Nick w MP: SzokoHD

Piwa: 23

Respekt: 50

Ja ju? tak zrobi?em jak wcze?niej poda? mi loop i dzia?a. Dziekuje wszystkim co chcieli pom?c :) :piwo:

Postaw piwo autorowi tego posta
 

 
Tagi: brak :: paliwa
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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