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

Wysłany: 2019-06-18, 09:54


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Siemka,
Mam problem gdy? mam kod na hud, ale problem jest w tym ?e nie mam poj?cia jak naprawi? to aby nie pojawia? si? w panelu logowania, tylko dopiero gdy zrespimy si? ju? w grze.

Kod:


local hud = {}
hud.state true
hud.gui false
hud.background nil
hud.pos nil
hud.nil
hud.nil
hud.font dxCreateFont("files/font.ttf"12)
pricedown dxCreateFont("files/pricedown.ttf"14)
pricedown2 dxCreateFont("files/pricedown.ttf"16)

local screen = {guiGetScreenSize()}
local screenX screen[1]
local screenY screen[2]
local scmp = (screenX/1920)
if screenX 1680 then
    scmp scmp*0.9
elseif screenX 1367 then
    scmp scmp*0.92
elseif screenX 1281 then
    scmp scmp*0.94
end

local ddx,ddy guiGetScreenSize()
function inbox(ddxddybxby)
    if isCursorShowing() then
        local mxmy getCursorPosition()
        mxmy mx*screenXmy*screenY
        bxby ddx+bxddy+by
        return ddx <= mx and bx >= mx and ddy <= my and by >= my
    end
end



local dotCounter 0



function createHUD()
    showPlayerHudComponent("clock"false)
    showPlayerHudComponent("health"false)
    showPlayerHudComponent("wanted"false)
    showPlayerHudComponent("money"false)
    showPlayerHudComponent("weapon"false)
    showPlayerHudComponent("ammo"false)
    showPlayerHudComponent("armour"false)
    if hud.state then
        if not hud.gui then
            hud.background guiCreateWindow(screenX-350*scmpscreenY-1220*scmp500*scmp,35*scmp""false)
            guiSetAlpha(hud.background0)
            guiWindowSetSizable(hud.backgroundfalse)
            hud.gui true
        end
        color1,color2,color3,alpha getElementData(localPlayer"guiColor") or 0,0,0,255
        hud.pos = {guiGetPosition(hud.backgroundfalse)}
        hud.hud.pos[1]
        hud.hud.pos[2]
        time getRealTime()
        name getPlayerName(localPlayer):gsub("_"" ")
        bartext ""
        br,bg,bb,ba 255,255,255,255
        maxnulls 12
        local money string.format("%08d"getPlayerMoney(getLocalPlayer()))
        finalnulls 12 string.len(tostring(money))
        finalString ""
        for i=1,finalnulls,do
            finalString finalString .. "0" 
        end
        dxDrawRectangle(hud.x+20*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,100)) -- HP bg
        dxDrawBorder(hud.x+20*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,255))

        dxDrawRectangle(hud.x+100*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,100)) -- Armor bg
        dxDrawBorder(hud.x+100*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,255))

        dxDrawRectangle(hud.x+180*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,100)) -- food bg
        dxDrawBorder(hud.x+180*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,255))
        
        dxDrawRectangle(hud.x+260*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,100)) -- drink bg
        dxDrawBorder(hud.x+260*scmphud.y+45*scmp65*scmp65*scmptocolor(0,0,0,255))

        health math.floor(getElementHealth(localPlayer)*1)
        dxDrawRectangle(hud.x+20*scmphud.y+45*scmp65*scmp0.65*health*scmptocolor(255,67,67,150)) -- HP
        if health 100 then
            dxDrawText(health .. "%"hud.x+30*scmp,hud.y+62*scmp65*scmp,  65*scmptocolor(255,255,255,255), 0.9hud.font)
        else
            dxDrawText(health .. "%"hud.x+25.8*scmp,hud.y+62*scmp65*scmp,  65*scmptocolor(255,255,255,255), 0.9hud.font)
        end

        armor math.floor(getPedArmor(localPlayer)*1)
        dxDrawRectangle(hud.x+100*scmphud.y+45*scmp65*scmp0.65*armor*scmptocolor(80,156,200,150)) -- Armor
        if armor 100 then
            dxDrawText(armor .. "%"hud.x+110*scmp,hud.y+62*scmp65*scmp,  65*scmptocolor(255,255,255,255), 0.9hud.font)
        else
            dxDrawText(armor .. "%"hud.x+105.8*scmp,hud.y+62*scmp65*scmp,  65*scmptocolor(255,255,255,255), 0.9hud.font)
        end

        dxDrawRectangle(hud.x+180*scmphud.y+45*scmp65*scmp65*scmptocolor(255,144,0,150)) -- food
        dxDrawText("100%"hud.x+185*scmp,hud.y+62*scmp65*scmp,  65*scmptocolor(255,255,255,255), 0.9hud.font)

        dxDrawRectangle(hud.x+260*scmphud.y+45*scmp65*scmp65*scmptocolor(124,197,118,150)) -- drink
        dxDrawText("100%"hud.x+265*scmp,hud.y+62*scmp65*scmp,  65*scmptocolor(255,255,255,255), 0.9hud.font)

        weapon getPedWeapon(localPlayer)

        if weapon then
            dxDrawImage(hud.x+80*scmp,hud.y+160*scmp256*scmp,  128*scmp"files/"..tonumber(weapon)..".png"0,0,0,tocolor(255,255,255,255))
        end
        dxDrawText(finalString.."#7CC576"..money.." $"hud.x+74*scmp,hud.y+120*scmp20*scmp,20*scmptocolor(255,255,255,255), 1pricedown2"left""top"falsefalsefalsetrue)
    end
end
addEventHandler("onClientRender"getRootElement(), createHUD)

--[[bindKey("M""down", 
    function()
        showCursor(not isCursorShowing())
    end
)]]

function toggleHUD()
    hud.state = (not hud.state)
    outputChatBox("Hud on/off")
end
addCommandHandler("toghud"toggleHUD)
addCommandHandler("Toghud"toggleHUD)
addCommandHandler("togglehud"toggleHUD)

function setData(cmddatavalue)
    if data and value then
        data tostring(data)
        value tonumber(value)
        setElementData(localPlayerdatavalue)
        outputChatBox(data.." to "..value)
    end
end
addCommandHandler("setdata"setData)

function resetHUD()
    if isElement(hud.backgroundthen
       destroyElement(hud.background)
       hud.gui false
       outputChatBox("Hud reseted.")
    end
end
addCommandHandler("resethud"resetHUD)
addCommandHandler("Resethud"resetHUD)
addCommandHandler("reshud"resetHUD)

function dxDrawBorder(lefttopwidthheight)
    --dxDrawRectangle(lefttopwidthheighttocolor(124197118150))
    dxDrawRectangle(left-1top-11height+2tocolor(000,255))
    dxDrawRectangle(left+widthtop-11height+2tocolor(000,255))
    dxDrawRectangle(lefttop-1width1tocolor(000,255))
    dxDrawRectangle(lefttop+heightwidth1tocolor(000,255))
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-18, 10:55


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Sprawdzasz czy gracz si? zalogowa? w funkcji kt?r? rysujesz ten HUD.

Mo?esz u?y? jakiej??elementDaty.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-18, 11:25


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Na przyk?ad jakiej? Jestem zielony w te sprawy

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-18, 12:34


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Takiej, w kt?rej zapisujesz stan zalogowania.
Zale?y co masz w kodzie logowania, mo?e ju? ustawiasz tam tak? elementDat?.
Poka? kod.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-18, 12:42


Remix110

Pewna osóbka :3






Wiek: 40
Na forum: 3663 dni
Posty: 291
Nick w MP: GoodNight

Piwa: 15

Respekt: 51

Daj element dat? w miejscu po zalogowaniu, w hudzie daj co? takiego: Je?eli jest zalogowany wtedy wy?wietl hud, a je?eli nie to nie wy?wietlaj. Bardzo proste i korzysta?em z tego na moim serwerze :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-06-22, 13:47


Kulegg







Wiek: 46
Na forum: 3125 dni
Posty: 283

Piwa: 20

Respekt: 50

Naprawione, dzi?ki

Postaw piwo autorowi tego posta
 

 
Tagi: hud :: pojawia :: się :: panelu :: logowania(inny :: kod)
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