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

Wysłany: 2013-06-25, 12:22


Drak







Wiek: 35
Na forum: 5044 dni
Posty: 71
Nick w MP: Drak

Piwa: 3

Respekt: 50

Mam problem z login panelem.


Oto kod:
GUIEditor = {
    tab = {},
    tabpanel = {},
    edit = {},
    button = {},
    window = {},
    label = {}
}
function loginWindow()

    GUIEditor.window[1] = guiCreateWindow(453, 323, 356, 321, "Login panel", false)
    guiWindowSetMovable(GUIEditor.window[1], false)
    guiWindowSetSizable(GUIEditor.window[1], false)
    guiSetAlpha(GUIEditor.window[1], 1.00)
    
    GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 23, 337, 288, false, GUIEditor.window[1])

    GUIEditor.tab[1] = guiCreateTab("Logowanie", GUIEditor.tabpanel[1])

    GUIEditor.label[1] = guiCreateLabel(36, 62, 111, 30, "Login:", false, GUIEditor.tab[1])
    guiSetFont(GUIEditor.label[1], "clear-normal")
    guiLabelSetColor(GUIEditor.label[1], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[1], "center")
    GUIEditor.edit[1] = guiCreateEdit(147, 62, 138, 29, "", false, GUIEditor.tab[1])
    GUIEditor.edit[2] = guiCreateEdit(147, 62, 138, 29, "", false, GUIEditor.tab[1])
    GUIEditor.edit[3] = guiCreateEdit(147, 62, 138, 29, "", false, GUIEditor.tab[1])
    GUIEditor.label[2] = guiCreateLabel(36, 62, 111, 30, "Login:", false, GUIEditor.tab[1])
    guiSetFont(GUIEditor.label[2], "clear-normal")
    guiLabelSetColor(GUIEditor.label[2], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[2], "center")
    GUIEditor.label[3] = guiCreateLabel(36, 62, 111, 30, "Login:", false, GUIEditor.tab[1])
    guiSetFont(GUIEditor.label[3], "clear-normal")
    guiLabelSetColor(GUIEditor.label[3], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[3], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[3], "center")
    GUIEditor.label[4] = guiCreateLabel(37, 92, 110, 31, "Has?o:", false, GUIEditor.tab[1])
    guiSetFont(GUIEditor.label[4], "clear-normal")
    guiLabelSetColor(GUIEditor.label[4], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[4], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[4], "center")
    GUIEditor.edit[4] = guiCreateEdit(147, 92, 138, 33, "", false, GUIEditor.tab[1])
    GUIEditor.button[1] = guiCreateButton(106, 176, 140, 52, "Zaloguj", false, GUIEditor.tab[1])
    guiSetFont(GUIEditor.button[1], "sa-header")
    guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FF00AAFF")

    GUIEditor.tab[2] = guiCreateTab("Rejestracja", GUIEditor.tabpanel[1])

    GUIEditor.label[5] = guiCreateLabel(67, 55, 87, 27, "Login:", false, GUIEditor.tab[2])
    guiSetFont(GUIEditor.label[5], "clear-normal")
    guiLabelSetColor(GUIEditor.label[5], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[5], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[5], "center")
    GUIEditor.label[6] = guiCreateLabel(68, 83, 86, 28, "Has?o:", false, GUIEditor.tab[2])
    guiSetFont(GUIEditor.label[6], "clear-normal")
    guiLabelSetColor(GUIEditor.label[6], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[6], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[6], "center")
    GUIEditor.label[7] = guiCreateLabel(69, 110, 85, 30, "Powt?rz Has?o:", false, GUIEditor.tab[2])
    guiLabelSetColor(GUIEditor.label[7], 0, 170, 255)
    guiLabelSetHorizontalAlign(GUIEditor.label[7], "center", false)
    guiLabelSetVerticalAlign(GUIEditor.label[7], "center")
    GUIEditor.edit[5] = guiCreateEdit(155, 55, 131, 27, "", false, GUIEditor.tab[2])
    GUIEditor.edit[6] = guiCreateEdit(156, 81, 130, 29, "", false, GUIEditor.tab[2])
    GUIEditor.edit[7] = guiCreateEdit(155, 110, 131, 30, "", false, GUIEditor.tab[2])
    GUIEditor.button[2] = guiCreateButton(89, 150, 177, 60, "Zarejestruj", false, GUIEditor.tab[2])
    guiSetFont(GUIEditor.button[2], "sa-header")
    guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF00AAFF")
    
    addEventHandler("onClientGUIClick", GUIEditor.button[1], onClickBtnLogin)
    addEventHandler("onClientGUIClick", GUIEditor.button[2], onClickBtnRegister)
end

function startLoginWindow()
    loginWindow()
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginWindow)

function loadLogins()
    local save_file = xmlLoadFile("konta/konta.xml")
    if not save_file then
        save_file = xmlCreateFile("konta/konta.xml", "login")
    end
    local login = xmlFindChild (save_file, "username", 0)
    local haslo = xmlFindChild (save_file, "password", 0)
    if login and haslo then
        return xmlNodeGetValue(login), xmlNodeGetValue(haslo)
    else
        return "", ""
    end
    xmlUnloadFile(save_file)
end

function saveLogins()
    local save_file = xmlLoadFile("konta/konta.xml")
    if not save_file then
        save_file = xmlCreateFile("konta/konta.xml", "login")
    end
    if (username ~= "")then
        local login = xmlFindChild (save_file, "username", 0)
        if not login then
            login = xmlCreateChild(save_file, "username")
        end
        xmlNodeSetValue (login, tostring(username))
    end
    if(password ~= "")then
        local haslo = xmlFindChild (save_file, "password", 0)
        if not haslo then
            haslo = xmlCreateChild(save_file, "password")
        end        
        xmlNodeSetValue (haslo, tostring(password))
    end
    xmlSaveFile(save_file)
    xmlUnloadFile (save_file)
end
addEvent("saveLogins", true)
addEventHandler("saveLoginsL", getRootElement(), saveLogins)

function resetSaveXML() 
        local save_file = xmlLoadFile("konta/konta.xml")
        if not save_file then
            save_file = xmlCreateFile("konta/konta.xml", "login")
        end
        if (username ~= "") then
            local login = xmlFindChild (save_file, "username", 0)
            if not login then
                login = xmlCreateChild(save_file, "username")
            end
        end
        if (haslo ~= "") then
            local haslo = xmlFindChild (save_file, "password", 0)
            if not haslo then
                haslo = xmlCreateChild(save_file, "password")
            end        
            xmlNodeSetValue (haslo, "")
        end
        xmlSaveFile(save_file)
        xmlUnloadFile (save_file)
end
addEvent("resetSaveXML", true)
addEventHandler("resetSaveXML", getRootElement(), resetSaveXML)

function onClickBtnLogin(button,state) 
    if(button == "left" and state == "up") then
        if (source == GUIEditor.button[1]) then
            username = guiGetText(GUIEditor.label[3])
            password = guiGetText(GUIEditor.label[4])
            triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password)
        end
    end
end

function onClickBtnRegister(button,state) 
    if(button == "left" and state == "up") then
        if (source == GUIEditor.button[2]) then
            username = guiGetText(GUIEditor.label[5])
            password = guiGetText(GUIEditor.label[6])
            passwordConfirm = guiGetText(GUIEditor.label[7])
            triggerServerEvent("onRequestRegister",getLocalPlayer(),username,password,passwordConfirm)
        end
    end
end

function hideLoginWindow()
    guiSetInputEnabled(false)
    guiSetVisible(GUIEditor.window[1], false)
    destroyElement(GUIEditor.window[1])
    GUIEditor.window[1] = nil
    showCursor(false)
    removeEventHandler("onClientGUIClick", GUIEditor.button[1], onClickBtnLogin)
end
addEvent("hideLoginWindow", true)
addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow)


Zero b??d?w w konsoli, a panel si? nie pojawia.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2013-07-01, 08:36


krisu477







Wiek: 25
Na forum: 4978 dni
Posty: 54
Nick w MP: Krisek

Piwa: 7

Respekt: 70

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startLoginWindow)
My?l?, ?e to trzeba zmieni? na:
addEventHandler("onClientPlayerJoin", getLocalPlayer(), startLoginWindow)
i reszt? przystosowa? do tego.

Postaw piwo autorowi tego posta
 

 
Tagi: login :: panel
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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