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

Wysłany: 2016-06-05, 22:08


teusz11







Wiek: 29
Na forum: 4652 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Witam, umie kto? ustawi? pr?dko?ciomierz na ?rodku ekranu na dole? jest na dole po prawej


g_root getRootElement()
g_rootElement getResourceRootElementgetThisResource() )
g_Player getLocalPlayer()

c_EnableScaling true

c_XOffset 10
c_YOffset 10
c_ImageW 200
c_ImageH 200
c_BarW 0
c_BarH 0
c_BarYOffset 70



c_FireTimeMs 5000
c_BarAlpha 120
c_BarFlashInterval 300

g_tFireStart nil

function drawNeedle()
    if not isPedInVehicle(g_Playerthen
        -- Fallback for player exiting car without onClientVehicleStartExit event
        --   (e.gfalling off a bike)
        hideSpeedometer()
    end
    local vehSpeed getVehicleSpeed()
    --local vehHealth getElementHealth(source,getPedOccupiedVehicle(g_Player))

    if vehHealth and (vehHealth 0then
        -- Show a little red/green health bar on the speedo
        local hp = (vehHealth-250)/750
        local curBarLen hp*g_BarW
        if curBarLen 1 then curBarLen 1 end

        local r 255*(hp)/0.5
        if 255 then r 255 end
        local g 255*hp/0.5
        if 255 then g 255 end
        if 0 then g 0 end
       
        if hp >= 0 then
            g_tFireStart nil
            dxDrawRectangle(g_ImageW/g_BarW/2g_BarYOffsetcurBarLeng_BarHtocolor(rg0c_BarAlpha))
        else
            if not g_tFireStart then g_tFireStart getTickCount() end
            local firePerc = (c_FireTimeMs - (getTickCount() - g_tFireStart)) / c_FireTimeMs
            if firePerc 0 then firePerc 0 end
            local a c_BarAlpha
            if (getTickCount()/c_BarFlashInterval)%1 then a 0 end
            dxDrawRectangle(g_ImageW/g_BarW/2g_BarYOffsetfirePerc*g_BarWg_BarHtocolor(25500a))
        end    
    end
    dxDrawImage(xyg_ImageWg_ImageH"needle.png"vehSpeed -13000whitetrue)
end


function showSpeedometer()
    guiSetVisible(disctrue)
    addEventHandler("onClientRender"g_rootdrawNeedle)
end
function hideSpeedometer()
    guiSetVisiblediscfalse)
    removeEventHandler("onClientRender"g_rootdrawNeedle)
end

function getVehicleSpeed()
    if isPedInVehicle(g_Playerthen
        local vxvyvz getElementVelocity(getPedOccupiedVehicle(g_Player))
        return math.sqrt(vx^vy^vz^2) * 161
    end
    return 0
end


addEventHandler("onClientVehicleEnter"g_root,
    function(thePlayer)
        if thePlayer == g_Player then
            showSpeedometer()
        end
    end
)

addEventHandler("onClientVehicleStartExit"g_root,
    function(thePlayer)
        if thePlayer == g_Player then
            hideSpeedometer()
        end
    end
)

function round(num)
    return math.floor(num 0.3)
end

function initGui()
    if disc then
        destroyElement(disc)
    end
    g_screenWidthg_screenHeight guiGetScreenSize()
    local scale
    if c_EnableScaling then
        scale = (g_screenWidth/1000 g_screenHeight/850)/2
    else
        scale 1
    end
    g_XOffset round(c_XOffset*scale)
    g_YOffset round(c_YOffset*scale)
    g_ImageW round(c_ImageW*scale)
    g_ImageH round(c_ImageH*scale)
    g_BarW round(c_BarW*scale)
    g_BarH round(c_BarH*scale)
    g_BarYOffset round(c_BarYOffset*scale)
    disc guiCreateStaticImage(g_screenWidth g_ImageW g_XOffsetg_screenHeight g_ImageH g_YOffsetg_ImageWg_ImageH"disc.png"false)
    xguiGetPosition(discfalse)
end

addEventHandler("onClientResourceStart"g_rootElement,
    function ()
        initGui()
        guiSetVisible(discfalse)
        setTimer(function()
            local wguiGetScreenSize()
            if (~= g_screenWidth) or (~= g_screenHeightthen
                initGui()
            end
        end5000)
        if isPedInVehicle(g_Playerthen
            showSpeedometer()
        end
    end
)


Postaw piwo autorowi tego posta
 

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


Jurandovsky

Kurdebele






Wiek: 17
Na forum: 4838 dni
Posty: 915

Piwa: 2697

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

local sw, sh = guiGetScreenSize()

(sw/2, sh - wysoko?? obrazka ) to jest chyba ?rodek, d?? ekranu

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: 2016-06-05, 22:33


teusz11







Wiek: 29
Na forum: 4652 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Na pocz?tku kodu jest napisane przez autora ?e jest wyliczone na praw? strone to chyba tam si? zmnienia


-- --> These values will be scaled with screen size
-- Offsets from the lower right screen corner
c_XOffset 10
c_YOffset 10
c_ImageW 200
c_ImageH 200
c_BarW 0
c_BarH 0
c_BarYOffset 70
-- <--


Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-06, 07:05


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3

Zmie? c_XOffset na wi?kszy.

Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-06, 23:23


teusz11







Wiek: 29
Na forum: 4652 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Dziex, mo?esz mi pom?c jeszcze z jedn? rzecz? ? mianowicie stworzy?em 6 zdj?? GuiCreateStaticImage, i tyle samo button?w na nich, z alpha 50%, jak zrobi? aby klikaj?c strza?kami g?ra, d?? zmienia? si? jeden button po zdj?ciach, albo po wci?ni?ciu jednego pojawia si? na jednym zdj?ciu potem 2 button itp

Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-07, 06:30


AteX







Wiek: 26
Na forum: 4015 dni
Posty: 927
Nick w MP: #AteX

Piwa: 8360

Respekt: 775,3
Respekt: 775,3Respekt: 775,3


Więcej informacji znajdziesz w Wikipedii MTA:

bindKey

i kombinuj z

Więcej informacji znajdziesz w Wikipedii MTA:

guiSetVisible


Podpis
MultiTheftAuto++ dla MTA 1.5.7 już dostępne.
Postaw piwo autorowi tego posta
 

 
Wysłany: 2016-06-07, 18:44


teusz11







Wiek: 29
Na forum: 4652 dni
Posty: 191
Nick w MP: Matevsz

Piwa: 4

Respekt: 50

Po klikni?ciu "lshift" jest button na zdj?ciu "zgas" je?li samoch?d ma zapalone lampy ale jak puszcze "lshift" to zostaje napis "zapal" . Dodam te? ?e jak wci?nie si? "lshift" to s? zapalone ?wiat?a a jak si? pu?ci to gasn?. Postawie :piwo:


function Swiatla()
    local pojazdyPrywatne getPedOccupiedVehicle(localPlayer)
    if pojazdyPrywatne then
        triggerServerEvent("swiatla"localPlayer)
        if getVehicleOverrideLights(pojazdyPrywatne) ~= 2 then
            guiSetVisible(zdjSwiatlatrue)
            guiSetVisible(zgastrue)
            guiSetVisible(zapalfalse)
        elseif 
            guiSetVisible(zdjSwiatlafalse)
            guiSetVisible(zgasfalse)
            guiSetVisible(zapaltrue)
            guiSetVisible(buttonfalse)
        end
    end
end
bindKey("lshift""both"Swiatla)


Postaw piwo autorowi tego posta
 

 
Tagi: speedometer :: center
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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