Jump to content

[HELP]Register


Metall

Recommended Posts

Hi i need help with my script, it isnt showing the GUI when i'm starting the script, and it's probably a fail in the code.

Client:

function createLoginWondow() 
        local X = 0.375 
        local Y = 0.375 
         
        local Width = 0.25 
        local Height = 0.25 
         
        wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) 
         
        X = 0.0825 
        Y = 0.2 
         
        Width = 0.25 
        Height = 0.25 
         
        guiCreateLabel(X, Y, Width, Height, "Username", true, wdwLogin) 
         
        Y = 0.5 
        guiCreateLabel(X, Y, Width, Height, "Password", true, wdwLogin) 
         
        X = 0.415 
        Y = 0.2 
        Width = 0.5 
        Height = 0.15 
        edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
        Y = 0.5 
        edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) 
        guiEditSetMaxLength(edtUser, 50) 
        guiEditSetMaxLength(edtPass, 50) 
         
        X = 0.415 
        Y = 0.7 
        Width = 0.25 
        Height = 0.2 
        btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) 
        guiSetVisible(wdwLogin, false) 
end 
  
addEventHandler("onClientResourceStart", getResourceElement(getThisResource()), 
        function () 
                createLoginWindow() 
                outPutChatBox("Welcome to Limitless, please login.") 
                 
                if (wdwLogin ~= nil) then 
                        guiSetVisible(wdwLogin, true) 
                else 
                 
                        outputChatBox("An Error has occured, and the login GUI hasnt been created") 
                end 
                 
                showCursor(true) 
                 
                guiSetInputEnabled(true) 
        end 
) 
  
addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
  
function createLoginWindow() 
  
... 
  
addEventHandler("onClientGUIClick", btnLogin, clientSubmitLogin, false) 
  
function clientSubmitLogin(button,state) 
    if button == "left" and state == "up" then 
         
        local username = guiGetText(edtUser) 
         
        local password = guiGetText(edtPass) 
  
         
        if username and password then 
  
            triggerServerEvent("submitLogin", getRootElement(), username, password) 
  
             
            guiSetInputEnabled(false) 
            guiSetVisible(wdwLogin, false) 
            showCursor(false) 
        else 
             
            outputChatBox("Please enter a username and password.") 
        end 
    end 
end 
  

server:

function loginHandler(username,password) 
  
    if username == "user" and password == "apple" then 
  
        if (client) then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
                        setCameraTarget(client, client) 
            outputChatBox("Welcome to My Server.", client) 
        end 
    else 
         
        outputChatBox("Invalid username and password. Please re-connect and try again.",client) 
        end          
end 
  
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler) 

meta:

<meta> 
     <script src="client.lua" type="client" /> 
     <script src="server.lua" type="server" /> 
</meta> 

Regards Metall, Newbie Scripter.

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...