Jump to content

Mi login pannel no aparece


Soren

Recommended Posts

Posted (edited)

Hola a todos hice este login pannel pero este no aparece cuando me meto al server

Client side:

function() 
GUIEditor_Window = {} 
GUIEditor_Button = {} 
GUIEditor_Label = {} 
GUIEditor_Edit = {} 
GUIEditor_Image = {} 
  
wdwLogin = guiCreateWindow(500,176,572,448,"",false) 
button = guiCreateButton(391,336,161,54,"Log-In",false,GUIEditor_Window[1]) 
guiSetFont(GUIEditor_Button[1],"sa-header") 
GUIEditor_Edit[1] = guiCreateEdit(39,24,293,267,"Alien Invasion.n/ Survive the Alien hordes . n/Scripted by ISoRen",false,GUIEditor_Window[1]) 
GUIEditor_Label[1] = guiCreateLabel(38,332,60,15,"Username",false,GUIEditor_Window[1]) 
username =  guiCreateEdit(99,330,156,25,"",false,GUIEditor_Window[1]) 
GUIEditor_Label[2] = guiCreateLabel(38,376,60,15,"Password",false,GUIEditor_Window[1]) 
pass = guiCreateEdit(99,371,156,25,"",false,GUIEditor_Window[1]) 
GUIEditor_Image[1] = guiCreateStaticImage(383,94,180,158,"images/mtalogo.png",false,GUIEditor_Window[1]) 
end 
  
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),  
    function () 
        -- create the log in window and its components 
        login() 
  
  
        -- if the GUI was successfully created, then show the GUI to the player 
            if (wdwLogin ~= nil) then 
            guiSetVisible(wdwLogin, true) 
        else 
            -- if the GUI hasnt been properly created, tell the player 
            outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") 
            end  
  
        -- enable the players cursor (so they can select and click on the components) 
            showCursor(true) 
        -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening 
            guiSetInputEnabled(true) 
    end 
) 
  
addEventHandler("onClientGUIClick", button, clientSubmitLogin, false) 
  
function clientSubmitLogin(button,state) 
    -- if our login button was clicked with the left mouse button, and the state of the mouse button is up 
    if button == "left" and state == "up" then 
        -- move the input focus back onto the game (allowing players to move around, open the chatbox, etc) 
        guiSetInputEnabled(false) 
        -- hide the window and all the components 
        guiSetVisible(wdwLogin, false) 
        -- hide the mouse cursor 
        showCursor(false) 
    end 
end 
  
function clientSubmitLogin(button,state) 
    if button == "left" and state == "up" then 
        -- get the text entered in the 'username' field 
        local username = guiGetText(username) 
        -- get the text entered in the 'password' field 
        local password = guiGetText(pass) 
  
        -- if the username and password both exist 
        if username and password then 
            -- trigger the server event 'submitLogin' and pass the username and password to it 
            triggerServerEvent("submitLogin", getRootElement(), username, password) 
  
            -- hide the gui, hide the cursor and return control to the player 
            guiSetInputEnabled(false) 
            guiSetVisible(wdwLogin, false) 
            showCursor(false) 
        else 
            -- otherwise, output a message to the player, do not trigger the server 
            -- and do not hide the gui 
            outputChatBox("Please enter a username and password.") 
        end 
    end 
end 

Server side:

-- create our loginHandler function, with username and password parameters (passed from the client gui) 
function loginHandler(username,password) 
  
end 
  
-- define our custom event, and allow it to be triggered from the client ('true') 
addEvent("submitLogin",true) 
-- add an event handler so that when submitLogin is triggered, the function loginHandler is called 
addEventHandler("submitLogin",root,loginHandler) 
  
function loginHandler(username,password) 
    -- check that the username and password are correct 
    if username == "user" and password == "apple" then 
        -- the player has successfully logged in, so spawn them 
        if (client) then 
            spawnPlayer(client, 1959.55, -1714.46, 10) 
            fadeCamera(client, true) 
                        setCameraTarget(client, client) 
            outputChatBox("Welcome to My Server.", client) 
        end 
    else 
        -- if the username or password are not correct, output a message to the player 
        outputChatBox("Invalid username and password. Please re-connect and try again.",client) 
        end          
end 
  
addEvent("submitLogin",true) 
addEventHandler("submitLogin",root,loginHandler) 

Que hice mal?

Edited by Guest
Posted

Primero que todo te equivocaste en los events ya que isiste copy and paste de la wiki donde dice wdw login tienes que poner la variable de tu Window osea GUIEditor_Window[1]

Posted
Primero que todo te equivocaste en los events ya que isiste copy and paste de la wiki donde dice wdw login tienes que poner la variable de tu Window osea GUIEditor_Window[1]

cierto no me habia fijado

Sigue sin funcionarme

Posted

ya se el problema es que mira tu pusiste como funcion de crear la GUI function login() y a las GUIs creada con Guieditor no se le puede agregar una function osea siempre tiene que ser function ()

Posted
ya se el problema es que mira tu pusiste como funcion de crear la GUI function login() y a las GUIs creada con Guieditor no se le puede agregar una function osea siempre tiene que ser function ()

Sigue sin :S

  • Recently Browsing   0 members

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