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

Wysłany: 2019-02-14, 15:35


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Witam ot??, mam spraw? umia? by kto? dorobi? mi element dat? vehicle:efuel, by np tankowa?o si? wi?cej ni? 100litr?w?
Kod
client
mojeW,mojeH 1360768
sW,sH guiGetScreenSize()
w= (sW/mojeW), (sH/mojeH)

bar guiCreateProgressBar(370*w552.6*h600*w43*hfalse)
guiSetVisible(bar,false)

label guiCreateLabel(50*w10*h460*w23*h"Paliwo : 100 % | Spacja : Tankowanie"falsebar)
guiLabelSetColor(label0090255)
guiLabelSetHorizontalAlign(label"center"false)
guiLabelSetVerticalAlign(label"center")

--x0,y0,z0 getElementPosition(m100)

--[[addEventHandler "onClientResourceStart"getResourceRootElement(getThisResource()),
    function()
        exports.customblips:createCustomBlip( -2029.65,156.79,28.8456"49.png" )
        exports.customblips:createCustomBlip( -2416.11,975.36,45.3056"49.png" )
        exports.customblips:createCustomBlip2149.53,2748.28,10.5056"49.png" )
        exports.customblips:createCustomBlip2202.44,2475.09,10.8256"49.png" )
        exports.customblips:createCustomBlip2114.87,919.88,10.5056"49.png" )
        exports.customblips:createCustomBlip2640.27,1106.91,10.5156"49.png" )
        exports.customblips:createCustomBlip611.97,1694.90,6.9956"49.png" )
        exports.customblips:createCustomBlip( -1328.90,2677.17,49.7456"49.png" )
        exports.customblips:createCustomBlip( -1470.59,1863.39,32.3156"49.png" )
        exports.customblips:createCustomBlip1381.37,458.11,19.6556"49.png" )
        exports.customblips:createCustomBlip655.36, -565.2816.3456"49.png" )
        exports.customblips:createCustomBlip( -1676.75,413.22,7.1856"49.png" )    
    end
)--]]

local stacje={
    {-2029.38157.2728.84-0.9},
    {-1681.69407.077.18-0.8},
    {-1678.54410.897.18-0.8},
    {-1672.26416.707.18-0.8},
}


for _,v in ipairs(stacje)do
    local marker=createMarker(v[1],v[2],v[3]-3.5,"cylinder",3,255,80,0)
    local x,y,getElementPosition(marker)
    setElementData(marker,"stacja",true)
    createBlipAttachedTo(marker56,2,255,0,0,255,1,275)
    --exports.customblips:createCustomBlipxy2020"49.png" )
end



addEventHandler("onClientMarkerHit",resourceRoot,function(e)
    if e==localPlayer then
        if getElementData(source,"stacja"then
            if getElementType(e)=="player" then
                if getPedOccupiedVehicle(ethen
                    if getElementData(getPedOccupiedVehicle(e),"vehicle:fuel")  then
                        guiSetVisible(bar,true)
                        guiSetVisible(barr,true)
                        guiSetText(label,"Paliwo : "..getElementData(getPedOccupiedVehicle(e),"vehicle:fuel").." L | Spacja : Tankowanie")
                        guiProgressBarSetProgress(bar,getElementData(getPedOccupiedVehicle(e),"vehicle:fuel"))
                        bindKey("space","down",tankuj)
                    end
                end
            end
        end
    end
end)

addEventHandler("onClientMarkerLeave",resourceRoot,function(e)
    if e==localPlayer then
        if getElementData(source,"stacja"then
            unbindKey("space","down",tankuj)
            guiSetVisible(bar,false)
            guiSetVisible(barr,false)
        end
    end
end)

function tankuj()
    if getPedOccupiedVehicle(localPlayerthen
        if getElementData(getPedOccupiedVehicle(localPlayer),"vehicle:fuel")>= 100 then return end
        triggerServerEvent("TANKUJ",localPlayer)
    end
end


addEvent("TANKUJ",true)
addEventHandler("TANKUJ",root,function()
    if source==localPlayer then
        local fuel=getElementData(getPedOccupiedVehicle(source),"vehicle:fuel")
        setElementData(getPedOccupiedVehicle(source),"vehicle:fuel",fuel+1)
        guiSetText(label,"Paliwo : "..getElementData(getPedOccupiedVehicle(source),"vehicle:fuel").." L | Spacja : Tankowanie")
        guiProgressBarSetProgress(bar,getElementData(getPedOccupiedVehicle(source),"vehicle:fuel"))
    end
end)

cpaliwo
--[[
    ResourceOURGame
    DevelopersSplit <split.programista@gmail.com>
    Copyright <split.programista@gmail.com2015-2016
    You have no right to use this code without my permission.
]]

-- Kod odpowiadaj?cy za odejmowanie paliwa oraz dodawanie paliwa
-- Wszelkie inne rzeczy sw systemie pojazd?// Split
local time=getTickCount()
local isBike={[509]=true,[481]=true,[510]=true}

local function naliczaj(veh)
    if getTickCount()-time>5000 then
        time getTickCount()
        local fuel getElementData(veh"vehicle:fuel") or 0
        local mileage getElementData(veh,"vehicle:mileage") or 0
        local vx,vy,vz getElementVelocity(veh)
        local spd=((vx^vy^vz^2)^(0.5)/2)
        if spd>0 then
            fuel fuel-(spd*2)/3
            setElementData(veh"vehicle:fuel"fuel)
            mileage mileage+(spd)
            setElementData(veh"vehicle:mileage"mileage)
        end
    end
end

addEventHandler("onClientRender"root, function()
    local vehicle getPedOccupiedVehicle(localPlayer)
    if not vehicle then return end
    if isBike[getElementModel(vehicle)] then return end
    if not getVehicleEngineState(vehiclethen return end
    if getElementData(vehicle,"vehicle:fuel") and getElementData(vehicle,"vehicle:fuel") or getElementData(vehicle,"vehicle:mileage") and getElementData(vehicle,"vehicle:mileage"then
        naliczaj(vehicle)
        if getElementData(vehicle,"vehicle:fuel")<1 then
            setVehicleEngineState(vehiclefalse)
        end

    end
end)

Daje piwko i respekt

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-14, 18:38


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Musia?e? usun?? warunek sprawdzaj?cy ilo?? paliwa, je?li by? wi?kszy lub r?wna? si? 100 funkcja si? ko?czy?a.
Podmie? client:

mojeW,mojeH 1360768
sW,sH guiGetScreenSize()
w= (sW/mojeW), (sH/mojeH)

bar guiCreateProgressBar(370*w552.6*h600*w43*hfalse)
guiSetVisible(bar,false)

label guiCreateLabel(50*w10*h460*w23*h"Paliwo : 100 % | Spacja : Tankowanie"falsebar)
guiLabelSetColor(label0090255)
guiLabelSetHorizontalAlign(label"center"false)
guiLabelSetVerticalAlign(label"center")

--x0,y0,z0 getElementPosition(m100)

--[[addEventHandler "onClientResourceStart"getResourceRootElement(getThisResource()),
    function()
        exports.customblips:createCustomBlip( -2029.65,156.79,28.8456"49.png" )
        exports.customblips:createCustomBlip( -2416.11,975.36,45.3056"49.png" )
        exports.customblips:createCustomBlip2149.53,2748.28,10.5056"49.png" )
        exports.customblips:createCustomBlip2202.44,2475.09,10.8256"49.png" )
        exports.customblips:createCustomBlip2114.87,919.88,10.5056"49.png" )
        exports.customblips:createCustomBlip2640.27,1106.91,10.5156"49.png" )
        exports.customblips:createCustomBlip611.97,1694.90,6.9956"49.png" )
        exports.customblips:createCustomBlip( -1328.90,2677.17,49.7456"49.png" )
        exports.customblips:createCustomBlip( -1470.59,1863.39,32.3156"49.png" )
        exports.customblips:createCustomBlip1381.37,458.11,19.6556"49.png" )
        exports.customblips:createCustomBlip655.36, -565.2816.3456"49.png" )
        exports.customblips:createCustomBlip( -1676.75,413.22,7.1856"49.png" )    
    end
)--]]

local stacje={
    {-2029.38157.2728.84-0.9},
    {-1681.69407.077.18-0.8},
    {-1678.54410.897.18-0.8},
    {-1672.26416.707.18-0.8},
}


for _,v in ipairs(stacje)do
    local marker=createMarker(v[1],v[2],v[3]-3.5,"cylinder",3,255,80,0)
    local x,y,getElementPosition(marker)
    setElementData(marker,"stacja",true)
    createBlipAttachedTo(marker56,2,255,0,0,255,1,275)
    --exports.customblips:createCustomBlipxy2020"49.png" )
end



addEventHandler("onClientMarkerHit",resourceRoot,function(e)
    if e==localPlayer then
        if getElementData(source,"stacja"then
            if getElementType(e)=="player" then
                if getPedOccupiedVehicle(ethen
                    if getElementData(getPedOccupiedVehicle(e),"vehicle:fuel")  then
                        guiSetVisible(bar,true)
                        guiSetVisible(barr,true)
                        guiSetText(label,"Paliwo : "..getElementData(getPedOccupiedVehicle(e),"vehicle:fuel").." L | Spacja : Tankowanie")
                        guiProgressBarSetProgress(bar,getElementData(getPedOccupiedVehicle(e),"vehicle:fuel"))
                        bindKey("space","down",tankuj)
                    end
                end
            end
        end
    end
end)

addEventHandler("onClientMarkerLeave",resourceRoot,function(e)
    if e==localPlayer then
        if getElementData(source,"stacja"then
            unbindKey("space","down",tankuj)
            guiSetVisible(bar,false)
            guiSetVisible(barr,false)
        end
    end
end)

function tankuj()
    if getPedOccupiedVehicle(localPlayerthen
        triggerServerEvent("TANKUJ",localPlayer)
    end
end


addEvent("TANKUJ",true)
addEventHandler("TANKUJ",root,function()
    if source==localPlayer then
        local fuel=getElementData(getPedOccupiedVehicle(source),"vehicle:fuel")
        setElementData(getPedOccupiedVehicle(source),"vehicle:fuel",fuel+1)
        guiSetText(label,"Paliwo : "..getElementData(getPedOccupiedVehicle(source),"vehicle:fuel").." L | Spacja : Tankowanie")
        guiProgressBarSetProgress(bar,getElementData(getPedOccupiedVehicle(source),"vehicle:fuel"))
    end
end)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Pyrek24
Wysłany: 2019-02-14, 23:53


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Okey mordko, a pokaza? by? mi co edytowa?e? link?, bym si? nauczy?

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-15, 06:09


ReDsKill







Wiek: 24
Na forum: 3256 dni
Posty: 35
Nick w MP: ReDsKill

Piwa: 1581

Respekt: 40,5

"Pyrek24" napisał/a:

Okey mordko, a pokaza? by? mi co edytowa?e? link?, bym si? nauczy?

Kolega wy?ej usun?? t? linijk?:

if getElementData(getPedOccupiedVehicle(localPlayer),"vehicle:fuel")>= 100 then return end


Podpis
Aktualny projekt: Santori RPG

Discord serwera: https://discord.gg/2BFEuSW
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Pyrek24
Wysłany: 2019-02-15, 11:07


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Okey, ale ja chce pod element dat? np ?e pod vehicle:fuel150 = 150 litr?w paliwa do zatankowania
vehicle:fuel100 = 100 litr?w oraz vehicle:fuel200 = 200litr?w

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-15, 12:43


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W funkcji tankuj dodaj:
if?getElementData(getPedOccupiedVehicle(localPlayer),"vehicle:fuel")>=?limit then?return?end

W miejsce s?owa limit wpisz liczb?, kt?ra b?dzie limitem paliwa.

Musisz zmodyfikowa? progressBar gdy? on ma limit 100, zr?b sobie

Więcej informacji znajdziesz w Wikipedii MTA:

dxDrawRectangle


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Pyrek24
Wysłany: 2019-02-15, 13:12


Pyrek24







Wiek: 25
Na forum: 3438 dni
Posty: 546
Nick w MP: Pyrek

Piwa: 10

Respekt: 50

Okey, ale ja to che pod 3 element daty, ?e jak zamontujesz element dat? vehicle:fuel150 to bd m?g? 150l zatankowa?

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Tagi: pojemność :: baku
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