Jump to content

Account GUI


therenex

Recommended Posts

Posted

Hey guys!

I wanna know if it is possible to do a login gui, i have something like this, client-side:

  
function joinHandler(player) 
  
    --boton de logueo 
    botonLogin = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Loguear", true ) 
  
    --creacion de cajas de escritura 
    usernameBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Usuario", true ) 
    passwordBox = guiCreateEdit( 0.3, 0.2, 0.4, 0.1, "Password", true ) 
    guiEditSetReadOnly ( usernameBox, false ) 
    guiEditSetReadOnly ( passwordBox, false ) 
  
    --funcion de logueo 
    function loginUser ( button ) 
        local user = guiGetText ( usernameBox ) --obtener usuario 
        local pass = guiGetText ( passwordBox ) --obtener contraseña 
        logIn ( user, pass ) -- loguear 
    end 
         
    --and attach our button to the outputEditBox function 
    addEventHandler ( "onClientGUIClick", botonLogin, loginUser ) 
     
end 
  

I know that logIn is a server-side function, so i want to know what should i do to make possible the login with this GUI.

Its based on the example of "guiCreateEdit".

What happens if i create an event on server-side script called loginEvent, i make an event handler for it with the function logIn and then i use triggerServerEvent on the clientside script? it would work?

Posted

What happens if i create an event on server-side script called loginEvent, i make an event handler for it with the function logIn and then i use triggerServerEvent on the clientside script? it would work?

That's the way it should be made. You get the data that player's entered and send it to the server-side script, which takes care of logging players in.

Posted

Add some outputChatBox or outputDebugString messages and see if they gets displayed if they will not, post your code here.

Posted

ok im trying to do a script with just this, as a gamemode.

this is what i have:

Client

function joinHandler(player) 
     
    fadeCamera ( true ) 
     
    --create our button 
    btnOutput = guiCreateButton( 0.7, 0.1, 0.2, 0.1, "Loguear", true ) 
  
    --Create an edit box and define it as "editBox". 
    usernameBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "Usuario", true ) 
    passwordBox = guiCreateEdit( 0.3, 0.2, 0.4, 0.1, "Password", true ) 
    guiEditSetMaxLength ( usernameBox, 128 ) --the max chatbox length is 128, so force this 
    guiEditSetMaxLength ( passwordBox, 128 ) --the max chatbox length is 128, so force this 
    guiEditSetReadOnly ( usernameBox, false ) 
    guiEditSetReadOnly ( passwordBox, false ) 
  
    --setup our function to output the message to the chatbox 
    function outputEditBox (button) 
        local user = guiGetText ( usernameBox )--get the text from the edit box 
        local pass = guiGetText ( passwordBox )--get the text from the edit box 
        outputChatBox ( "..." ) 
        triggerServerEvent ( "loginEvent", getLocalPlayer(), getLocalPlayer(), user, pass ) 
    end 
     
    --and attach our button to the outputEditBox function 
    addEventHandler ( "onClientGUIClick", btnOutput, outputEditBox ) 
     
end 
  
addEventHandler('onClientPlayerJoin', getRootElement(), joinHandler) 

Server

addEvent ( "loginEvent", true ) 
addEventHandler ( "loginEvent", getRootElement(), logIn ) 

now i dont see anything on the screen! :shock:

damn this sounds so lame.

Posted

change

addEventHandler('onClientPlayerJoin', getRootElement(), joinHandler) 

to

addEventHandler("onClientPlayerJoin", getRootElement(), joinHandler) 

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

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