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

Wysłany: 2020-11-08, 18:07


Pyrek24







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

Piwa: 10

Respekt: 50

Witam, co mam ?le w tworzeniu editboxa?
Kod na editboxy
c_side

local xguiGetScreenSize ( )
local sx,sy x,y
function isMouseInPosition xywidthheight )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sxsy guiGetScreenSize ( )
    local cxcy getCursorPosition ( )
    local cxcy = ( cx sx ), ( cy sy )
    if ( cx >= and cx <= width ) and ( cy >= and cy <= height then
        return true
    else
        return false
    end
end
        function deleteLastLetter(text,ile)
            if tostring(text) and tonumber(ilethen
                asd utf8.sub(text1string.len(text)-ile)
                return asd
            end
            return false
        end
        bold dxCreateFont ("Raleway-Bold.ttf"9)
        light dxCreateFont ("Raleway-Light.ttf"12)
        medium dxCreateFont ("Raleway-Medium.ttf"20)
dxGui={
    allowLetters={ "0""1""2""3""4""5""6""7""8""9""a""b""c""d""e""f""g""h""i""j""k","l""m""n""o""p""q""r""s""t""u""v""w""x""y""z"},
    button={}, -- zrobione
    combobox={}, --naprawione git
    gridlist={},
    window={}, -- w miare git
    checkbox={}, -- git
    editbox={}, -- git
    scroll={},-- nie dziala pobieranie statusu

}

addEventHandler("onClientRender"root,function()
    for k,v in pairs(dxGui["button"]) do
        if #dxGui.button > 0 and v.visible == true then
            dxDrawRectangle(v.xv.yv.wv.h,tocolor(0,0,0,tonumber(v.alpha)),true)
            dxDrawRectangle(v.x+2v.y+2v.w-4v.h-4    ,tocolor(186,186,186,tonumber(v.alpha)-100),true)
            dxDrawText v.text v.xv.yv.x+v.wv.y+v.htocolor 255255255150 ),1medium,"center""center",false,false,true)
            if isMouseInPosition(v.xv.yv.wv.hthen
                dxGui.button[v.id].alpha 180
            else
                dxGui.button[v.id].alpha 150
            end
        end
    end
    -- window
    for k,v in pairs(dxGui["window"]) do
        if #dxGui.window > 0 and v.visible == true then
            dxDrawRectangle(v.xv.yv.wv.h,tocolor(0,0,0,tonumber(v.alpha)))
            dxDrawRectangle(v.x+10v.y+20v.w-20v.h-30,tocolor(186,186,186,tonumber(v.alpha)-100))
            dxDrawRectangle(v.xv.yv.w20,tocolor(0,0,0,tonumber(v.alpha)-50))
            dxDrawText v.text v.xv.yv.x+v.wv.y+v.htocolor 255255255150 ), 1bold,"center""top")
        end
    end
    for k,v in pairs(dxGui["editbox"]) do
        if #dxGui.editbox > 0 and v.visible == true then
            --dxDrawRectangle(v.xv.yv.wv.htocolor(255,255,255,tonumber(v.alpha)), true)
            --dxDrawRectangle(v.x+5v.y+5v.w-10v.h-10,tocolor(186,186,186,tonumber(v.alpha)+10))
            if v.zamaskowanyy == false then
            dxDrawText v.text v.xv.yv.x+v.wv.y+v.htocolor 255,255,255255 ), 1medium,"left""center",false,false,true)
            else
            dxDrawText v.text:gsub(".","*") , v.xv.yv.x+v.wv.y+v.htocolor 255,255,255255 ), 1medium,"left""center",false,false,true)
            end
        end
    end
    for k,v in pairs(dxGui["checkbox"]) do
        if #dxGui.checkbox > 0 and v.visible == true then
            if v.click == true then
                dxDrawRectangle(v.xv.yv.wv.wtocolor(255,255,255,tonumber(v.alpha)), true)
                dxDrawRectangle(v.x+5v.y+5v.w-10v.w-10,tocolor(0,0,0,255),true)
            else
                dxDrawRectangle(v.xv.yv.wv.wtocolor(255,255,255,tonumber(v.alpha)), true)
                dxDrawRectangle(v.x+5v.y+5v.w-10v.w-10,tocolor(255,255,255,tonumber(v.alpha)+20),true)
            end
        end
    end
    for _,v in pairs(dxGui["combobox"]) do
        if #dxGui.combobox > 0 and v.visible == true then
            if v.click == false then
                dxDrawRectangle(v.xv.yv.wv.htocolor(255,255,255,tonumber(v.alpha)), true)
                dxDrawText v.item v.xv.yv.x+v.wv.y+v.htocolor 000255 ), 1light,"center""center",false,false,true)
            elseif v.click == true then
                if #dxGui.combobox[v.id].items > 0 then
                    dxDrawRectangle(v.xv.yv.wv.htocolor(255,255,255,tonumber(v.alpha)), true)
                    dxDrawText v.item v.xv.yv.x+v.wv.y+v.htocolor 000255 ), 1light,"center""center",false,false,true)
                    for k,item in pairs(dxGui["combobox"][v.id]["items"]) do
                        dxDrawRectangle(v.xv.y+40*kv.wv.htocolor(0,0,0,tonumber(v.alpha)), true)
                        dxDrawText (tostring(item), v.xv.y+80*kv.x+v.wv.y+v.htocolor 255255255255 ), 1light,"center""center",false,false,true)
                    end
                end
            end
        end
    end
    for _,v in pairs(dxGui["scroll"]) do
        if #dxGui.scroll > 0 and v.visible == true then
            dxDrawRectangle(v.xv.yv.wv.htocolor(0,0,0,tonumber(v.alpha)), true)
            scrollStatus v.w/100
            dxDrawRectangle(v.wSv.yv.w/10v.htocolor(255,255,255,tonumber(v.alpha)), true)-- TO JEST MALY KWADRACIK
                if getKeyState("mouse1"then
                    if isMouseInPosition(v.wSv.yv.w/10v.h)  then
                        local x,getCursorPosition()
                        local cxcy = (sx*x), (sy*y)
                        if cx >= v.x+((v.w/10)/2) and cx <= v.x+v.w-((v.w/10)/2then
                            v.wS cx-((v.w/10)/2)
                            dxGui["scroll"][v.id].status scrollStatus*v.wS-v.x
                            outputChatBox(dxGui["scroll"][v.id].status)
                        end
                    end
                end
        end
    end
end)
addEventHandler("onClientClick",root,function(btn,state)
    if btn and getKeyState("mouse1") and state then
        for k,v in pairs(dxGui["button"]) do
            if #dxGui.button > 0 and v.visible then
                if isMouseInPosition(v.xv.yv.wv.hthen
                    if type(v.funkcja) == "function" then
                        v.funkcja()
                    end
                end
            end
        end
        for k,v in pairs(dxGui["editbox"]) do
        dxGui.editbox[v.id].click false
            if #dxGui.editbox > 0 and v.visible then
                if isMouseInPosition(v.xv.yv.wv.hthen
                    dxGui.editbox[v.id].click true
                end
            end
        end
        for k,v in pairs(dxGui["checkbox"]) do
            if #dxGui.checkbox > 0 and v.visible then
                if isMouseInPosition(v.xv.yv.wv.wthen
                    if v.click == false then
                        dxGui.checkbox[v.id].click true
                    else
                        dxGui.checkbox[v.id].click false
                    end
                end
            end
        
        end
        for _,v in pairs(dxGui["combobox"]) do
            if #dxGui["combobox"] > 0 and v.visible then
                if v.click == false then
                    if isMouseInPosition(v.xv.yv.wv.h)  then
                        dxGui.combobox[v.id].click true
                    end
                else
                    for k,item in pairs(dxGui["combobox"][v.id]["items"]) do
                        if isMouseInPosition(v.xv.y+40*kv.wv.hthen
                            dxGui.combobox[v.id].click false
                            dxGui["combobox"][v.id].item dxGui["combobox"][v.id]["items"][k]
                        end
                    end
                end
            end
        end
    end
end)
--button
function dxCreateButton(iddxdydwdhdtextd,funkcjad)
        dxGui.button[idd] = {
            visible true,
            id idd,
            xd,
            yd,
            wd,
            hd,
            text textd,
            alpha 150,
            funkcja funkcjad
        }
end



function dxSetButtonText(idtext)
    dxGui.button[id].text text
end

function dxButtonSetVisible(idbool)
    dxGui.button[id].visible bool or false
end
--window
function dxCreateWindow(iddxdydwdhdtextd)
        dxGui.window[idd] = {
            visible true,
            id idd,
            xd,
            yd,
            wd,
            hd,
            text textd,
            alpha 150,
        }
end
function dxSetWindowText(idtext)
    dxGui.window[id].text text
end

function dxWindowSetVisible(idbool)
    dxGui.window[id].visible bool or false
    
end
--editbox
function dxCreateEdit(idd,maskaxdydwdhd)
        dxGui.editbox[idd] = {
            visible true,
            id idd,
            zamaskowanyy maska,
            xd,
            yd,
            wd,
            hd,
            click false,
            text "",
            alpha 200,
        }
end

function dxEditGetText(id)
    return dxGui.editbox[id].text 
end

function dxEditSetVisible(idbool)
    dxGui.editbox[id].visible bool or false
    
end

addEventHandler("onClientKey",root,function(buttonpress)
    if press then
        for k,v in pairs(dxGui["editbox"]) do
            if v.click == true then
                if button == "backspace" then
                    if #dxGui.editbox[v.id].text > 0 then
                        dxGui.editbox[v.id].text deleteLastLetter(dxGui.editbox[v.id].text1)
                    end
                else
                    for k,litera in pairs(dxGui["allowLetters"]) do
                        if #dxGui.editbox[v.id].text < 16 then 
                            if button == litera and getKeyState("lshift"then
                                dxGui.editbox[v.id].text dxGui.editbox[v.id].text..string.upper(litera)
                                break
                            end
                            if button == litera then
                                dxGui.editbox[v.id].text dxGui.editbox[v.id].text ..litera
                            end
                        end
                    end
                end
            end
        end
    end
end)

--checkbox
function dxCreateCheckbox(iddxdydwd)
        dxGui.checkbox[idd] = {
            visible true,
            id idd,
            xd,
            yd,
            wd,
            click false,
            alpha 200,
        }
end

function dxCheckboxGetClicked(id)
    return dxGui.checkbox[id].click 
end

function dxCheckboxSetVisible(idbool)
    dxGui.checkbox[id].visible bool or false
    
end
--combobox
function dxCreateCombobox(iddxdydwd,hd)
        dxGui.combobox[idd] = {
            visible true,
            id idd,
            xd,
            yd,
            wd,
            hd,
            click false,
            items = {},
            item "",
            alpha 200,
        }
end
function dxComboboxAddItem(idtext)
    table.insert(dxGui.combobox[id].itemstext)
end
function dxComboboxSetVisible(idbool)
    dxGui.combobox[id].visible bool or false
end
function dxComboboxGetItemText(id)
    return dxGui.combobox[id].item
end
--scroll1

function dxCreateScroll(iddxdydwd,hdwS)
        dxGui.scroll[idd] = {
            visible true,
            id idd,
            xd,
            yd,
            wd,
            hd,
            wS xd,
            status 0,
            alpha 200,
        }
end
function dxScrollSetVisible(idbool)
    dxGui.scroll[id].visible bool or false
end
function dxScrollGetStatus(id)
    return dxGui.scroll[id].status
end

Kod kt?ry wywo?uje tworzenie editboxa

addEventHandler("onClientRender"root,
    function()
       -- dxDrawRectangle(71834030779tocolor(255255255255), false)
        dxDrawRectangle(676284547170tocolor(100115), false)
    exports["dx"]:dxCreateEdit("login","TEST",679287540167);
    exports["dx"]:dxEditSetVisible("login"true);    
    
    end
)

Wszystkie warto?ci uzupe?ni?em, editbox dalej si? nie tworzy.

Podpis
amta
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-08, 18:18


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Masz zakomentowane w renderze rectangle ktore bodajze tworza twoj edit


for k,v in pairs(dxGui["editbox"]) do
        if #dxGui.editbox > 0 and v.visible == true then
            --dxDrawRectangle(v.xv.yv.wv.htocolor(255,255,255,tonumber(v.alpha)), true)
            --dxDrawRectangle(v.x+5v.y+5v.w-10v.h-10,tocolor(186,186,186,tonumber(v.alpha)+10))
            if v.zamaskowanyy == false then
            dxDrawText v.text v.xv.yv.x+v.wv.y+v.htocolor 255,255,255255 ), 1medium,"left""center",false,false,true)
            else
            dxDrawText v.text:gsub(".","*") , v.xv.yv.x+v.wv.y+v.htocolor 255,255,255255 ), 1medium,"left""center",false,false,true)
            end
        end
    end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-08, 18:54


Pyrek24







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

Piwa: 10

Respekt: 50

Sprawdz?, by?em pewien ?e tak funkcja tworzy m?j edit

function dxCreateEdit(idd,maskaxdydwdhd)
        dxGui.editbox[idd] = {
            visible true,
            id idd,
            zamaskowanyy maska,
            xd,
            yd,
            wd,
            hd,
            click false,
            text "",
            alpha 200,
        }
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-08, 18:55


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Ona tylko dodaje ci dane do tabeli, a odtwarzanie tabeli masz w renderze.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-08, 18:59


Pyrek24







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

Piwa: 10

Respekt: 50

Shuffle, stworzy?em editboxa wed?ug tego wzoru

for k,v in pairs(dxGui["editbox"]) do
        if #dxGui.editbox > 0 and v.visible == true then
            --dxDrawRectangle(v.xv.yv.wv.htocolor(255,255,255,tonumber(v.alpha)), true)
            --dxDrawRectangle(v.x+5v.y+5v.w-10v.h-10,tocolor(186,186,186,tonumber(v.alpha)+10))
            if v.zamaskowanyy == false then
            dxDrawText v.text v.xv.yv.x+v.wv.y+v.htocolor 255,255,255255 ), 1medium,"left""center",false,false,true)
            else
            dxDrawText v.text:gsub(".","*") , v.xv.yv.x+v.wv.y+v.htocolor 255,255,255255 ), 1medium,"left""center",false,false,true)
            end
        end
    end



kod

    exports["dx"]:dxCreateEdit("login",679287540167255255255255true);

Dalej nie dzia?a, 0 b??d?w.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-10, 13:47


MeeShuffle

Programista/Grafik






Wiek: 32
Na forum: 4394 dni
Posty: 2758
Nick w MP: Shuffle

Piwa: 8575

Respekt: 535,3
Respekt: 535,3

Jak ma on wygl?da?? Bo nadal masz zakomentowane dxDrawRectangle

Postaw piwo autorowi tego posta
 

 
Tagi: editboxy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » editboxy Odpowiedz do tematu

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