Jump to content

Help with my login window


SoundWave

Recommended Posts

Posted

this is the login_c.lua

--******************** 
--*  Login window    * 
--* Made By:         * 
--*   ~EPG~SoundWave * 
--******************** 
  
ACCOUNT_LOGIN_SAVE           = "account.xml" 
  
function buildLoginWindow(s) 
    if (g_screenX >= 723) and (g_screenY >= 420) then 
        local gui = {} 
        gui._placeHolders = {} 
     
        local screenWidth, screenHeight = guiGetScreenSize() 
        local windowWidth, windowHeight = 723, 420 
        local left = screenWidth/2 - windowWidth/2 
        local top = screenHeight/2 - windowHeight/2 
        loginWindow = guiCreateWindow(left, top, windowWidth, windowHeight, "ECR Login Window", false) 
        guiWindowSetSizable(loginWindow, false) 
     
        gui["tabLabel1"] = guiCreateTabPanel(10, 25, 401, 291, false, loginWindow) 
     
        gui["tab"] = guiCreateTab("Welcome", gui["tabLabel1"]) 
     
        gui["plainTextEdit_2"] = guiCreateMemo(10, 10, 371, 241, "Welcome to the Elite Command Racers DD/DM server!\n\n\nThe rules are:\n- Don’t use cheats, hacks, or any other kind that gives you advantages.\n- Don't try insult or swear\n- Do not advertise any other clans or servers!\n- Do not camp.\n- Do not block on DMs\n\n\nHave fun!\n\nGrtz. The ECR clan.", false, gui["tab"]) 
        guiMemoSetReadOnly(gui["plainTextEdit_2"], true) 
     
        gui["tab_3"] = guiCreateTab("Crew", gui["tabLabel1"]) 
         
        gui["plainTextEdit_3"] = guiCreateMemo(10, 10, 381, 241, "Leaders", false, gui["tab_3"]) 
     
        gui["tab_2"] = guiCreateTab("Some Info", gui["tabLabel1"]) 
         
        gui["plainTextEdit"] = guiCreateMemo(10, 10, 371, 241, "haha :D", false, gui["tab_2"]) 
        guiMemoSetReadOnly(gui["plainTextEdit"], true) 
         
        gui["pushButton"] = guiCreateButton(575, 325, 135, 41, "Login", false, loginWindow) 
        addEventHandler("onClientGUIClick", gui["pushButton"], on_login_clicked, false) 
         
        gui["pushButton_2"] = guiCreateButton(430, 325, 135, 41, "Register", false, loginWindow) 
        addEventHandler("onClientGUIClick", gui["pushButton_2"], on_register_clicked, false) 
         
        nickField = guiCreateEdit(90, 325, 301, 31, "", false, loginWindow) 
        guiEditSetMaxLength(nickField, 255) 
         
        passField = guiCreateEdit(90, 375, 301, 31, "", false, loginWindow) 
        guiEditSetMaxLength(passField, 255) 
         
        gui["label_3"] = guiCreateLabel(20, 325, 61, 21, "Nickname:", false, loginWindow) 
        guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
        guiLabelSetVerticalAlign(gui["label_3"], "center") 
         
        gui["label_4"] = guiCreateLabel(20, 375, 61, 21, "Password:", false, loginWindow) 
        guiLabelSetHorizontalAlign(gui["label_4"], "left", false) 
        guiLabelSetVerticalAlign(gui["label_4"], "center") 
         
        autoLogInOrNot = guiCreateCheckBox(580, 385, 141, 17, "Enable serial log-in", false, false, loginWindow) 
         
        gui["pushButton_3"] = guiCreateButton(430, 375, 121, 31, "Guest-mode", false, loginWindow) 
        if on_login_as_guest then 
            addEventHandler("onClientGUIClick", gui["pushButton_3"], on_login_as_guest, false) 
        end 
         
        guiCreateStaticImage(430, 45, 280, 270, "ECR.png", false, loginWindow) 
    else 
        local gui = {} 
        gui._placeHolders = {} 
         
        local screenWidth, screenHeight = guiGetScreenSize() 
        local windowWidth, windowHeight = 480, 367 
        local left = screenWidth/2 - windowWidth/2 
        local top = screenHeight/2 - windowHeight/2 
        loginWindow = guiCreateWindow(left, top, windowWidth, windowHeight, "ECR Login Window", false) 
        guiWindowSetSizable(loginWindow, false) 
         
        gui["tabLabel1"] = guiCreateTabPanel(10, 25, 461, 241, false, loginWindow) 
         
        gui["tab"] = guiCreateTab("Welcome", gui["tabLabel1"]) 
         
        gui["plainTextEdit_2"] = guiCreateMemo(10, 10, 441, 201, "Welcome to the Elite Command Racers DD/DM server!\n\n\nThe rules are:\n- Don’t use cheats, hacks, or any other kind that gives you advantages.\n- Don't try insult or swear\n- Do not advertise any other clans or servers!\n- Do not camp.\n- Do not block on DMs\n\n\nHave fun!\n\nGrtz. The ECR clan.", false, gui["tab"]) 
        guiMemoSetReadOnly(gui["plainTextEdit_2"], true) 
         
        gui["tab_3"] = guiCreateTab("Crew", gui["tabLabel1"]) 
         
        gui["plainTextEdit_3"] = guiCreateMemo(10, 10, 441, 201, "Leaders", false, gui["tab_3"]) 
         
        gui["tab_2"] = guiCreateTab("Some Info", gui["tabLabel1"]) 
         
        gui["plainTextEdit"] = guiCreateMemo(10, 10, 441, 201, "haha :D", false, gui["tab_2"]) 
        guiMemoSetReadOnly(gui["plainTextEdit"], true) 
         
        gui["pushButton"] = guiCreateButton(280, 275, 91, 41, "Register", false, loginWindow) 
        addEventHandler("onClientGUIClick", gui["pushButton"], on_register_clicked, false) 
         
        nickField = guiCreateEdit(90, 275, 181, 31, "", false, loginWindow) 
        guiEditSetMaxLength(nickField, 255) 
         
        passField = guiCreateEdit(90, 325, 181, 31, "", false, loginWindow) 
        guiEditSetMaxLength(passField, 255) 
         
        gui["label_3"] = guiCreateLabel(20, 275, 61, 21, "Nickname:", false, loginWindow) 
        guiLabelSetHorizontalAlign(gui["label_3"], "left", false) 
        guiLabelSetVerticalAlign(gui["label_3"], "center") 
         
        gui["label_4"] = guiCreateLabel(20, 325, 61, 21, "Password:", false, loginWindow) 
        guiLabelSetHorizontalAlign(gui["label_4"], "left", false) 
        guiLabelSetVerticalAlign(gui["label_4"], "center") 
         
        autoLogInOrNot = guiCreateCheckBox(360, 335, 121, 17, "Enable serial log-in", false, false, loginWindow) 
         
        gui["pushButton_3"] = guiCreateButton(280, 325, 71, 31, "Guest-mode", false, loginWindow) 
        addEventHandler("onClientGUIClick", gui["pushButton_3"], on_login_as_guest, false) 
         
        gui["pushButton_2"] = guiCreateButton(380, 275, 91, 41, "Login", false, loginWindow) 
        addEventHandler("onClientGUIClick", gui["pushButton_2"], on_login_clicked, false) 
    end 
     
    guiEditSetMasked(passField, true) 
    local xmlFile = xmlLoadFile(ACCOUNT_LOGIN_SAVE) 
    if xmlFile then 
        toggle  = xmlNodeGetAttribute(xmlFile,"enabled") == "true" 
        if toggle then 
            local S_NICK = tostring(xmlNodeGetAttribute(xmlFile,"nick")) 
            local S_PASS = tostring(xmlNodeGetAttribute(xmlFile,"pass")) 
            guiSetText(nickField,S_NICK) 
            guiSetText(passField,S_PASS) 
            triggerServerEvent("onPlayerJoinData", g_Me,S_NICK, S_PASS, "login") 
            outputChatBox("#FFFFFFSetting#009900: [ #FFFFFFTo disable auto login, use #009900/#FFFFFFstopauto #009900]", 255,255,255,true)   
        end 
        xmlUnloadFile(xmlFile) 
    end 
    guiSetInputEnabled(true) 
    return gui, windowWidth, windowHeight 
end 
  
  
function on_login_as_guest() 
    showCursor(false) 
    guiSetInputEnabled(false) 
    guiSetVisible(loginWindow,false) 
    triggerServerEvent("onPlayerLoginAsGuest", g_Me) 
end 
  
function on_login_clicked() 
        local nick = guiGetText(nickField) 
        local pass = guiGetText(passField) 
        if(pass ~= "" and pass ~= nil and nick ~= "" and nick ~= nil) then 
            if (guiCheckBoxGetSelected(autoLogInOrNot) ~= false) then 
                handleXMLSave() 
            end 
            triggerServerEvent("onPlayerJoinData", g_Me, nick, pass, "login") 
        else 
            outputChatBox("#FFFFFFError#009900: [ #FFFFFFYou forgot to fill in a field #009900]", 255,255,255,true) 
    end 
end 
  
function on_register_clicked() 
        local nick = guiGetText(nickField) 
        local pass = guiGetText(passField) 
        if(pass ~= "" and pass ~= nil and nick ~= "" and nick ~= nil) then 
            triggerServerEvent("onPlayerJoinData", g_Me, nick, pass, "register") 
        else 
            outputChatBox("#FFFFFFError#009900: [ #FFFFFFYou forgot to fill in a field #009900]", 255,255,255,true) 
    end 
end 
  
addEvent("onPlayerSuccesLogIn", true) 
addEventHandler("onPlayerSuccesLogIn", getRootElement(), 
    function () 
        showCursor(false) 
        guiSetInputEnabled(false) 
        guiSetVisible(loginWindow,false) 
    end 
) 
  
function handleXMLSave() 
    local xmlFile = xmlLoadFile(ACCOUNT_LOGIN_SAVE) 
    if not xmlFile then 
        xmlFile = xmlCreateFile("account.xml","settings") 
         
        if not xmlFile then 
            outputDebugString("Login settings could not be saved",1) 
            return 
        end 
    end 
     
    xmlNodeSetAttribute(xmlFile,"enabled",tostring(true)) 
    xmlNodeSetAttribute(xmlFile,"nick",tostring(guiGetText(nickField))) 
    xmlNodeSetAttribute(xmlFile,"pass",tostring(guiGetText(passField))) 
     
    xmlSaveFile(xmlFile) 
    xmlUnloadFile(xmlFile) 
end 
  
function removeAutoLi() 
    local xmlFile = xmlLoadFile(ACCOUNT_LOGIN_SAVE) 
    if xmlFile then 
        toggle  = xmlNodeGetAttribute(xmlFile,"enabled") 
            if toggle == "true" then 
                xmlNodeSetAttribute(xmlFile,"enabled",tostring(false)) 
                outputChatBox("#FFFFFFSetting#009900: [ #FFFFFFYou've disabled the auto-login #009900]", 255,255,255,true) 
                outputChatBox("#FFFFFFSetting#009900: [ #FFFFFFNext time you join, are you able to log in with a different account #009900]",255,255,0) 
                xmlSaveFile(xmlFile) 
                xmlUnloadFile(xmlFile) 
            else 
                outputChatBox("#FFFFFFSetting#009900: [ #FFFFFFThe auto-login is already disabled#009900! ]", 255,255,255,true) 
                xmlUnloadFile(xmlFile) 
            end 
    end 
end 
addCommandHandler("stopauto", removeAutoLi) 
  
function playerLoggedOut() 
    dxDrawIsOn = nil 
    guiSetVisible(loginWindow, true) 
    guiSetText(nickField, "") 
    guiSetText(passField, "") 
    guiCheckBoxSetSelected(autoLogInOrNot, false) 
    showCursor(true) 
    guiSetInputEnabled(true) 
    triggerServerEvent("onPlayerLogOutDX",g_Me) 
    local xmlFile = xmlLoadFile(ACCOUNT_LOGIN_SAVE) 
    if xmlFile then 
        toggle  = xmlNodeGetAttribute(xmlFile,"enabled") 
        if toggle == "true" then 
            xmlNodeSetAttribute(xmlFile,"enabled",tostring(false)) 
            xmlSaveFile(xmlFile) 
             
        end 
    xmlUnloadFile(xmlFile) 
    end 
end 

This is my login_s.lua

--******************** 
--*  Login window    * 
--* Made By:         * 
--*   ~EPG~SoundWave * 
--******************** 
  
function onLogin ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    else 
        outputChatBox ( "Wrong username or password!", player, 255, 255, 0 ) -- Output they got the details wrong. 
    end 
end 
  
addEvent( "onLogin", true ) 
addEventHandler( "onLogin", getRootElement(), onLogin ) 
  
function onRegister ( player, user, pass ) 
    local account = getAccount ( user, pass ) 
    if ( account ~= false ) then 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    else 
        account = addAccount ( user, pass ) 
        if (logIn ( player, account, pass ) == true) then 
            triggerClientEvent ( "hideLoginWindow", getRootElement()) 
        else 
            outputChatBox ( "Register/Login error!", player, 255, 255, 0 ) -- Output they got the details wrong. 
        end 
    end 
end 
  
addEvent( "onRegister", true ) 
addEventHandler( "onRegister", getRootElement(), onRegister ) 

And this is the Meta.xml

<meta> 
    <info author="SoundWave" type="misc" name="Login Window" description="logingui." version="1.0"/> 
    <script src="login_c.lua" type="client"/> 
    <file src="ECR.png"/> 
</meta> 

I dont know what is wrong because i don't get an error plz help.

Posted

so you expect people to check every line of that load of code you've posted?

from what i can tell from quick look:

1. g_screenX, g_screenY, g_Me — not defined anywhere

2. lots of strange unused variables like dxDrawIsOn, gui._placeHolders

3. server file is not in meta.xml

4. server and client events absolutely different.

etc etc

it all looks like a part of some other resource(s), isn't it?

Posted

checked.

scripts are totally different, nothing matches to each other.

SoundWave, stop stealing resources.

Also you should at least not pretending it's yours by putting these "credits" comments on the top of script.

Shame on you.

Topic locked.

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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