iFoReX Posted May 9, 2012 Share Posted May 9, 2012 If a player put a nick or password bad the GUI disappear D: help me please cl-side GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Radio = {} LoginWindow = guiCreateWindow(0.2763,0.3467,0.4863,0.3633,"Ventana de Loggeo",true) guiWindowSetMovable(LoginWindow,false) guiWindowSetSizable(LoginWindow,false) GUIEditor_Label[1] = guiCreateLabel(21,63,52,21,"Nick :",false,LoginWindow) guiSetFont(GUIEditor_Label[1],"clear-normal") GUIEditor_Edit[1] = guiCreateEdit(63,58,126,28,"",false,LoginWindow) GUIEditor_Label[2] = guiCreateLabel(19,110,74,19,"Contraseña : ",false,LoginWindow) GUIEditor_Edit[2] = guiCreateEdit(94,105,126,28,"",false,LoginWindow) GUIEditor_Label[3] = guiCreateLabel(19,147,227,19,"Si no Tienes una Cuenta registrate aqui : ",false,LoginWindow) guiLabelSetColor(GUIEditor_Label[3],255,0,0) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Button[1] = guiCreateButton(19,168,100,36,"Registrarme",false,LoginWindow) GUIEditor_Checkbox[1] = guiCreateCheckBox(227,107,115,27,"Recordar Datos",false,false,LoginWindow) guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") GUIEditor_Button[2] = guiCreateButton(229,55,97,35,"Logearme",false,LoginWindow) GUIEditor_Label[4] = guiCreateLabel(196,188,181,16,"GUI Creada por ElMota (c) 2012",false,LoginWindow) guiLabelSetColor(GUIEditor_Label[4],255, 255, 0) guiSetFont(GUIEditor_Label[4],"default-bold-small") GUIEditor_Radio[1] = guiCreateRadioButton(17,26,81,21,"Español",false,LoginWindow) guiRadioButtonSetSelected(GUIEditor_Radio[1],true) GUIEditor_Radio[2] = guiCreateRadioButton(109,26,81,21,"English",false,LoginWindow) RegisterWindow = guiCreateWindow(0.2937,0.3533,0.4437,0.3517,"Ventana de Registrarse",true) guiWindowSetMovable(RegisterWindow,false) guiWindowSetSizable(RegisterWindow,false) GUIEditor_Label[5] = guiCreateLabel(11,26,142,17,"Pon datos que no Olvides",false,RegisterWindow) guiSetFont(GUIEditor_Label[5],"default-bold-small") GUIEditor_Label[6] = guiCreateLabel(9,52,140,20,"---Datos Importantes.",false,RegisterWindow) guiSetFont(GUIEditor_Label[6],"default-bold-small") GUIEditor_Label[7] = guiCreateLabel(12,85,52,21,"Nick :",false,RegisterWindow) guiSetFont(GUIEditor_Label[7],"clear-normal") GUIEditor_Edit[3] = guiCreateEdit(50,80,100,26,"",false,RegisterWindow) GUIEditor_Label[8] = guiCreateLabel(12,127,87,17,"Contraseña :",false,RegisterWindow) guiSetFont(GUIEditor_Label[8],"clear-normal") GUIEditor_Edit[4] = guiCreateEdit(100,122,100,26,"",false,RegisterWindow) GUIEditor_Label[9] = guiCreateLabel(12,179,42,16,"Sexo :",false,RegisterWindow) guiSetFont(GUIEditor_Label[9],"clear-normal") GUIEditor_Radio[3] = guiCreateRadioButton(62,174,65,25,"Hombre",false,RegisterWindow) guiRadioButtonSetSelected(GUIEditor_Radio[3],true) guiSetFont(GUIEditor_Radio[3],"default-bold-small") GUIEditor_Radio[4] = guiCreateRadioButton(134,174,65,25,"Mujer",false,RegisterWindow) guiSetFont(GUIEditor_Radio[4],"default-bold-small") GUIEditor_Label[10] = guiCreateLabel(216,29,52,16,"ESPAÑOL",false,RegisterWindow) guiLabelSetColor(GUIEditor_Label[10],0,0,255) guiSetFont(GUIEditor_Label[10],"default-bold-small") GUIEditor_Label[11] = guiCreateLabel(294,29,52,16,"ENGLISH",false,RegisterWindow) guiLabelSetColor(GUIEditor_Label[11],0,0,255) guiSetFont(GUIEditor_Label[11],"default-bold-small") GUIEditor_Button[3] = guiCreateButton(215,69,123,39,"Registrarme !",false,RegisterWindow) guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,false) guiEditSetMasked(GUIEditor_Edit[2],false) guiEditSetMasked(GUIEditor_Edit[4],false) showCursor(false) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,true) showCursor(true) guiSetText(GUIEditor_Edit[1], ""..getPlayerName( localPlayer ).."") end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[1] then guiSetVisible(RegisterWindow,true) guiSetVisible(LoginWindow,false) elseif source == GUIEditor_Button[2] then guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,false) showCursor(false) elseif source == GUIEditor_Button[3] then guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,false) showCursor(false) end end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then local username = guiGetText(GUIEditor_Edit[1]) local password = guiGetText(GUIEditor_Edit[2]) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) guiSetVisible(LoginWindow, false) guiSetVisible(RegisterWindow, false) showCursor(false) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientSubmitLogin, false) sv-side function loginHandler(username,password) local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) Link to comment
Castillo Posted May 9, 2012 Share Posted May 9, 2012 You must trigger a event from server side when he successfully logs in. -- client side: GUIEditor_Button = {} GUIEditor_Checkbox = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Radio = {} LoginWindow = guiCreateWindow(0.2763,0.3467,0.4863,0.3633,"Ventana de Loggeo",true) guiWindowSetMovable(LoginWindow,false) guiWindowSetSizable(LoginWindow,false) GUIEditor_Label[1] = guiCreateLabel(21,63,52,21,"Nick :",false,LoginWindow) guiSetFont(GUIEditor_Label[1],"clear-normal") GUIEditor_Edit[1] = guiCreateEdit(63,58,126,28,"",false,LoginWindow) GUIEditor_Label[2] = guiCreateLabel(19,110,74,19,"Contraseña : ",false,LoginWindow) GUIEditor_Edit[2] = guiCreateEdit(94,105,126,28,"",false,LoginWindow) GUIEditor_Label[3] = guiCreateLabel(19,147,227,19,"Si no Tienes una Cuenta registrate aqui : ",false,LoginWindow) guiLabelSetColor(GUIEditor_Label[3],255,0,0) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Button[1] = guiCreateButton(19,168,100,36,"Registrarme",false,LoginWindow) GUIEditor_Checkbox[1] = guiCreateCheckBox(227,107,115,27,"Recordar Datos",false,false,LoginWindow) guiSetFont(GUIEditor_Checkbox[1],"default-bold-small") GUIEditor_Button[2] = guiCreateButton(229,55,97,35,"Logearme",false,LoginWindow) GUIEditor_Label[4] = guiCreateLabel(196,188,181,16,"GUI Creada por ElMota (c) 2012",false,LoginWindow) guiLabelSetColor(GUIEditor_Label[4],255, 255, 0) guiSetFont(GUIEditor_Label[4],"default-bold-small") GUIEditor_Radio[1] = guiCreateRadioButton(17,26,81,21,"Español",false,LoginWindow) guiRadioButtonSetSelected(GUIEditor_Radio[1],true) GUIEditor_Radio[2] = guiCreateRadioButton(109,26,81,21,"English",false,LoginWindow) RegisterWindow = guiCreateWindow(0.2937,0.3533,0.4437,0.3517,"Ventana de Registrarse",true) guiWindowSetMovable(RegisterWindow,false) guiWindowSetSizable(RegisterWindow,false) GUIEditor_Label[5] = guiCreateLabel(11,26,142,17,"Pon datos que no Olvides",false,RegisterWindow) guiSetFont(GUIEditor_Label[5],"default-bold-small") GUIEditor_Label[6] = guiCreateLabel(9,52,140,20,"---Datos Importantes.",false,RegisterWindow) guiSetFont(GUIEditor_Label[6],"default-bold-small") GUIEditor_Label[7] = guiCreateLabel(12,85,52,21,"Nick :",false,RegisterWindow) guiSetFont(GUIEditor_Label[7],"clear-normal") GUIEditor_Edit[3] = guiCreateEdit(50,80,100,26,"",false,RegisterWindow) GUIEditor_Label[8] = guiCreateLabel(12,127,87,17,"Contraseña :",false,RegisterWindow) guiSetFont(GUIEditor_Label[8],"clear-normal") GUIEditor_Edit[4] = guiCreateEdit(100,122,100,26,"",false,RegisterWindow) GUIEditor_Label[9] = guiCreateLabel(12,179,42,16,"Sexo :",false,RegisterWindow) guiSetFont(GUIEditor_Label[9],"clear-normal") GUIEditor_Radio[3] = guiCreateRadioButton(62,174,65,25,"Hombre",false,RegisterWindow) guiRadioButtonSetSelected(GUIEditor_Radio[3],true) guiSetFont(GUIEditor_Radio[3],"default-bold-small") GUIEditor_Radio[4] = guiCreateRadioButton(134,174,65,25,"Mujer",false,RegisterWindow) guiSetFont(GUIEditor_Radio[4],"default-bold-small") GUIEditor_Label[10] = guiCreateLabel(216,29,52,16,"ESPAÑOL",false,RegisterWindow) guiLabelSetColor(GUIEditor_Label[10],0,0,255) guiSetFont(GUIEditor_Label[10],"default-bold-small") GUIEditor_Label[11] = guiCreateLabel(294,29,52,16,"ENGLISH",false,RegisterWindow) guiLabelSetColor(GUIEditor_Label[11],0,0,255) guiSetFont(GUIEditor_Label[11],"default-bold-small") GUIEditor_Button[3] = guiCreateButton(215,69,123,39,"Registrarme !",false,RegisterWindow) guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,false) guiEditSetMasked(GUIEditor_Edit[2],false) guiEditSetMasked(GUIEditor_Edit[4],false) showCursor(false) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,true) showCursor(true) guiSetText(GUIEditor_Edit[1], ""..getPlayerName( localPlayer ).."") end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[1] then guiSetVisible(RegisterWindow,true) guiSetVisible(LoginWindow,false) elseif source == GUIEditor_Button[3] then guiSetVisible(RegisterWindow,false) guiSetVisible(LoginWindow,false) showCursor(false) end end ) function clientSubmitLogin ( button, state ) if ( button == "left" and state == "up" ) then local username = guiGetText(GUIEditor_Edit[1]) local password = guiGetText(GUIEditor_Edit[2]) if ( username and password ) then triggerServerEvent("submitLoginEM", localPlayer, username, password) else outputChatBox("Porfavor pon tu Nick y tu Contrase?a.") end end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientSubmitLogin, false) addEvent ( "closeLoginGUI", true ) addEventHandler ( "closeLoginGUI", root, function ( ) guiSetVisible ( LoginWindow, false ) guiSetVisible ( RegisterWindow, false ) showCursor ( false ) end ) -- server side: function loginHandler(username,password) local acc = getAccount(username, password) if (acc) then logIn ( source, acc, password ) fadeCamera(source, true) setCameraTarget(source) triggerClientEvent ( source, "closeLoginGUI", source ) outputChatBox("Enjoy your time!", source) else outputChatBox("invalid username and password. Please re-connect and try again.", source) end end addEvent("submitLoginEM",true) addEventHandler("submitLoginEM",root, loginHandler) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now