Jump to content

[Help]Login Panel


Best-Killer

Recommended Posts

when i login it's still black screen

codes :

client

GUIEditor = { 
    tab = {},
    label = {},
    tabpanel = {},
    edit = {},
    button = {},
    window = {},
    checkbox = {},
    memo = {}
}
 
 
addEventHandler("onClientResourceStart", resourceRoot,
    function()
local screenW, screenH = guiGetScreenSize()
        GUIEditor.window[1] = guiCreateWindow((screenW - 626) / 2, (screenH - 612) / 2, 626, 612, "Login Panel", false)
        guiWindowSetSizable(GUIEditor.window[1], false)
        guiSetAlpha(GUIEditor.window[1], 1.00)
        guiSetVisible(GUIEditor.window[1], false)
 
        GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 312, 607, 290, false, GUIEditor.window[1])
 
        GUIEditor.tab[1] = guiCreateTab("Updates", GUIEditor.tabpanel[1])
 
        GUIEditor.memo[1] = guiCreateMemo(10, 10, 582, 241, "HERE PUT UPDATES!!!", false, GUIEditor.tab[1])
        guiMemoSetReadOnly(GUIEditor.memo[1], true)
 
 
        GUIEditor.button[1] = guiCreateButton(345, 282, 124, 45, "Login", false, GUIEditor.window[1])
        GUIEditor.button[2] = guiCreateButton(479, 282, 127, 45, "Register", false, GUIEditor.window[1])
       
        GUIEditor.label[1] = guiCreateLabel(11, 30, 96, 34, "Username:", false, GUIEditor.window[1])
        GUIEditor.label[2] = guiCreateLabel(11, 92, 96, 34, "Password : ", false, GUIEditor.window[1])
       
        GUIEditor.edit[1] = guiCreateEdit(125, 26, 161, 38, "", false, GUIEditor.window[1])
        GUIEditor.edit[2] = guiCreateEdit(125, 82, 161, 38, "", false, GUIEditor.window[1])
        guiEditSetMasked(GUIEditor.edit[2], true)
        GUIEditor.checkbox[1] = guiCreateCheckBox(52, 157, 369, 15, "While registering/logging you accept to follow all server rules.", true, false, GUIEditor.window[1])
        guiSetFont(GUIEditor.checkbox[1], "default-bold-small")
        guiSetProperty(GUIEditor.checkbox[1], "NormalTextColour", "FF23FE00")
        GUIEditor.label[3] = guiCreateLabel(440, 41, 176, 89, "2015 @ All rights reserved. ", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.label[3], "default-bold-small")
        guiLabelSetColor(GUIEditor.label[3], 255, 0, 0)
        guiLabelSetHorizontalAlign(GUIEditor.label[3], "left", true)    
        GUIEditor.label[4] = guiCreateLabel(43, 217, 546, 47, "Always read the rules before playing!", false, GUIEditor.window[1])
        GUIEditor.button[3] = guiCreateButton(211, 282, 124, 45, "Recover Account", false, GUIEditor.window[1])    
    end
)
 
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        local screenW, screenH = guiGetScreenSize()
        reg = guiCreateWindow((screenW - 690) / 2, (screenH - 506) / 2, 690, 506, "Register a account!", false)
        guiWindowSetSizable(reg, false)
        guiSetAlpha(reg, 1.00)
 
        register = guiCreateButton(228, 447, 229, 49, "I AM DONE!", false, reg)
        guiSetProperty(register, "NormalTextColour", "FFFF0000")
        backBtn = guiCreateButton(22, 27, 107, 31, "Go back!", false, reg)    
        editbox = guiCreateEdit(139, 62, 526, 37, "", false, reg)
        sLb1 = guiCreateLabel(32, 68, 97, 15, "Username:", false, reg)
        editbox1 = guiCreateEdit(139, 136, 526, 37, "", false, reg)
        guiEditSetMasked(editbox1, true)
        sLb2 = guiCreateLabel(36, 146, 97, 15, "Password:", false, reg)
        sLb3 = guiCreateLabel(36, 229, 97, 15, "Repeat Password:", false, reg)
        editbox2 = guiCreateEdit(139, 217, 526, 37, "", false, reg)
        guiEditSetMasked(editbox2, true)
        sAnswer = guiCreateEdit(139, 296, 526, 37, "", false, reg)
        sLb4 = guiCreateLabel(36, 308, 97, 15, "Secret answer!", false, reg)
        sLb5 = guiCreateLabel(37, 351, 647, 86, "Don't tell your password or secret answer to anyone!", false, reg)    
    end
)
 
 
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        local screenW, screenH = guiGetScreenSize()
        registerWindow = guiCreateWindow((screenW - 516) / 2, (screenH - 461) / 2, 516, 461, "Recover account", false)
        guiWindowSetSizable(registerWindow, false)
        guiSetVisible(registerWindow, false)
        guiSetAlpha(registerWindow, 1.00)
 
        usernameR = guiCreateEdit(156, 51, 208, 37, "", false, registerWindow)
        myLabelS = guiCreateLabel(44, 64, 112, 34, "Acc username:", false, registerWindow)
        guiSetFont(myLabelS, "default-bold-small")
        secretAnswerR = guiCreateEdit(156, 113, 208, 37, "", false, registerWindow)
        myLabel2 = guiCreateLabel(44, 126, 112, 34, "Secret answer:", false, registerWindow)
        guiSetFont(myLabel2, "default-bold-small")
        goBack = guiCreateButton(23, 37, 73, 24, ">> BACK!", false, registerWindow)
        submitR = guiCreateButton(113, 390, 272, 49, "I finished.", false, registerWindow)
        myLabel1 = guiCreateLabel(18, 199, 488, 163, "We are not able to do anything if you lost your secret answer or username. ", false, registerWindow)    
    end
)
 
    function setWarningText(text, r, g, b)
        if not text or not r or not g or not b then
            return
        end
        guiSetText(GUIEditor.label[4], tostring(text))
        guiLabelSetColor(GUIEditor.label[4], r, g, b)
    end
    addEvent('setWarning', true)
    addEventHandler('setWarning', root, setWarningText)
 
    function setRegisterWarningText(text, r, g, b)
        if not text or not r or not g or not b then
            return
        end
        guiSetText(sLb5, tostring(text))
        guiLabelSetColor(sLb5, r, g, b)        
    end
    addEvent('setRegisterWarning', true)
    addEventHandler('setRegisterWarning', root, setRegisterWarningText)
 
    function windowHandler( )
        local playername = getPlayerName(localPlayer)
        guiSetText(GUIEditor.edit[1], "")
        guiSetText(GUIEditor.edit[2], "")
        setWarningText("Always read the rules before playing!", 0, 255, 0)
        setRegisterWarningText("Don't tell your password or secret answer to anyone!", 0, 255, 0)
        guiSetVisible ( GUIEditor.window[1], false )
        guiSetVisible ( reg, false )
        guiSetInputEnabled( false )
        showCursor ( false )
    end
    addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), windowHandler )
   
    function playerPressedKey(s)
        elements = {
                    GUIEditor.edit[1],
                    GUIEditor.edit[2],
                    sAnswer,
                    editbox,
                    editbox1,
                    editbox2,
                    secretAnswerR,
                    usernameR,
                    }
        triggers = {
            "isValidUsername",
            "isValidPassword",
            "isValidSecretAnswer",
            "isValidUsername",
            "isValidPassword",
            "isValidPassword",
            "isValidSecretAnswer",
            "isValidUsername",
                    }
        parents = {
                    "setWarning",
                    "setWarning",
                    "setRecoverText",
                    "setRegisterWarning",
                    "setRegisterWarning",
                    "setRegisterWarning",
                    "setRecoverText",
                    "setRecoverText"
                  }
        for k,v in ipairs(elements) do
            if v == s then
                if elements[k] == elements[4] then
                    triggerServerEvent("isValidR", localPlayer, guiGetText(s), parents[k])
                else
                    triggerServerEvent(triggers[k], localPlayer, guiGetText(s), parents[k])
                end
            end
        end
    end
    addEventHandler("onClientGUIChanged", guiRoot, playerPressedKey)
            function resetFields()
            guiSetText(sAnswer, "")
            guiSetText(editbox2, "")
            guiSetText(editbox, "")
            guiSetText(usernameR, "")
            guiSetText(GUIEditor.edit[1], "")
            guiSetText(GUIEditor.edit[2], "")
            guiSetText(secretAnswerR, "")
            guiSetText(editbox1, "")
        end
    addEvent('resetFields', true)
    addEventHandler('resetFields', root,resetFields )
 
 
    function login ()
        if (source == GUIEditor.button[1]) then
            if guiCheckBoxGetSelected( GUIEditor.checkbox[1] ) == true then
                triggerServerEvent ( "onLogin",getRootElement(), localPlayer, guiGetText(GUIEditor.edit[1]), guiGetText(GUIEditor.edit[2]) )
            else
                triggerServerEvent("kickPlayer", localPlayer)
            end
        end
    end
     addEventHandler ( "onClientGUIClick", guiRoot, login )
     
        function setRecoverText(text, r, g, b)
            guiLabelSetColor(myLabel1, r, g, b)
            guiSetText(myLabel1, tostring(text))
        end
        addEvent("setRecoverText", true)
        addEventHandler("setRecoverText", root, setRecoverText)
 
       function recover(button, state)
            if (button == "left" and state == "up") then
                if source == goBack then
                    guiSetVisible( registerWindow, false )
                    guiSetVisible( GUIEditor.window[1], true )
                    resetFields()
                elseif source == submitR then
                    local acc = guiGetText(usernameR)
                    local secret = guiGetText(secretAnswerR)
                    if secret == "" then
                        setRecoverText("Please type something at editbox of secret answer.", 255, 0, 0)
                        return
                    elseif acc == "" then
                        setRecoverText("No account entered! Sorry!", 255, 0, 0)
                        return
                    end
                    triggerServerEvent("recoverAccount", localPlayer, localPlayer, acc, secret)
                end
            end
        end
        addEventHandler('onClientGUIClick', guiRoot, recover)
     
         function register(button,state)
    if (button == "left" and state == "up") then
        if (source == register) then
            username = guiGetText(editbox)
            password = guiGetText(editbox1)
            passwordConfirm = guiGetText(editbox2)
            secretAnswer = guiGetText(sAnswer)
            if secretAnswer == "" then
                setRegisterWarningText("Please type the secret answer!", 255, 0, 0)
                return
            end
            triggerServerEvent("onRegister",getRootElement(), localPlayer,username,password,passwordConfirm, secretAnswer)
        elseif (source == backBtn) then
            closeRegisterGUI()
        end
    end
end
addEventHandler ( "onClientGUIClick", guiRoot, register )
     function GUIs ()
     if (source == GUIEditor.button[2]) then
       guiSetVisible ( reg, true )
       guiSetVisible ( GUIEditor.window[1], false )
       showCursor ( true )
     elseif (source == GUIEditor.button[3] ) then
        guiSetVisible( GUIEditor.window[1], false )
        guiSetVisible( registerWindow, true )
    end
end
Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...