therenex Posted March 16, 2008 Share Posted March 16, 2008 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? Link to comment
50p Posted March 16, 2008 Share Posted March 16, 2008 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. Link to comment
therenex Posted March 16, 2008 Author Share Posted March 16, 2008 i tried that but nothing happens =/ just... nothing, i dont even get anything with debugscript or in console... Link to comment
50p Posted March 16, 2008 Share Posted March 16, 2008 Add some outputChatBox or outputDebugString messages and see if they gets displayed if they will not, post your code here. Link to comment
therenex Posted March 17, 2008 Author Share Posted March 17, 2008 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! damn this sounds so lame. Link to comment
Brophy Posted March 17, 2008 Share Posted March 17, 2008 change addEventHandler('onClientPlayerJoin', getRootElement(), joinHandler) to addEventHandler("onClientPlayerJoin", getRootElement(), joinHandler) Link to comment
therenex Posted March 17, 2008 Author Share Posted March 17, 2008 im not going to do this anymore. if you want, just close the topic. Link to comment
Recommended Posts