PhantomDamn Posted January 14, 2014 Share Posted January 14, 2014 Hola amigos, tengo un problema y es que quiero activar un login panel y el spawn que uso actualmente.. pero el spawn queda montado sobre el login y la idea es que el login aparesca solo cuando un player entra este es el client side del login : function createLoginWindow() GUIEditor_Button = {} GUIEditor_Image = {} window = guiCreateWindow(254,137,303,307,"~CG~ Login Panel",false) guiSetAlpha(window,0.60000002384186) guiWindowSetMovable(window,false) guiWindowSetSizable(window,false) logo = guiCreateStaticImage(62,23,187,38,"images/logo.png",false,window) guiSetAlpha(logo,1) username_l = guiCreateLabel(7,75,289,24," Username:",false,window) guiSetAlpha(username_l,1) guiLabelSetColor(username_l,20, 100, 100) guiLabelSetVerticalAlign(username_l,"top") guiLabelSetHorizontalAlign(username_l,"left",false) guiSetFont(username_l,"clear-normal") username = guiCreateEdit(9,100,285,25,"",false,window) guiSetAlpha(username,1) password_l = guiCreateLabel(7,140,289,24," Password:",false,window) guiSetAlpha(password_l,1) guiLabelSetColor(password_l,20,100,100) guiLabelSetVerticalAlign(password_l,"top") guiLabelSetHorizontalAlign(password_l,"left",false) guiSetFont(password_l,"clear-normal") password = guiCreateEdit(9,168,285,25,"",false,window) guiSetAlpha(password,1) GUIEditor_Button[1] = guiCreateButton(9,245,143,53,"Login",false,window) guiSetAlpha(GUIEditor_Button[1],1) GUIEditor_Button[2] = guiCreateButton(153,245,135,53,"Register",false,window) guiSetAlpha(GUIEditor_Button[2],1) errorl = guiCreateLabel(7,212,288,24,"",false,window) guiSetAlpha(errorl,1) guiLabelSetColor(errorl,20, 100, 100) guiLabelSetVerticalAlign(errorl,"top") guiLabelSetHorizontalAlign(errorl,"left",false) GUIEditor_Button[4] = guiCreateButton(0.8931,0.0644,0.0692,0.0706,"X",true,window) guiSetAlpha(GUIEditor_Button[4],1) addEventHandler("onClientGUIClick", GUIEditor_Button[1], clientSubmitLogin, false) addEventHandler("onClientGUIClick", GUIEditor_Button[2], clientSubmitRegister, false) addEventHandler("onClientGUIClick", GUIEditor_Button[4], onClickGuest) end -- Boutons -- GUIEditor_Button[1] = guiCreateButton(0.0298,0.7843,0.3212,0.1863,"HEHO",true,GUIEditor_Window[1]) -- GUIEditor_Button[2] = guiCreateButton(0.3709,0.7843,0.2781,0.1863,"HEHO",true,GUIEditor_Window[1]) -- GUIEditor_Button[3] = guiCreateButton(0.6722,0.7843,0.298,0.1863,"HEHO",true,GUIEditor_Window[1]) -- -- Guest mode function onClickGuest(button,state) if(button == "left" and state == "up") then if (source == GUIEditor_Button[4]) then guiSetVisible(window, false) guiSetInputEnabled(false) showCursor(false) if blackLoginScreen == true then fadeCamera(true,removeBlackScreenTime) end end end end function resourceStart() createLoginWindow() if (window ~= nil) then guiSetVisible(window, true) else outputChatBox("An error has occurred.") end showCursor(true) guiSetInputEnabled(true) end -- ADDED function imageFunc() image = guiCreateStaticImage(0,0,798,599,"images/backgroundlogin.png",false) guiSetProperty(image,"Disabled","true") -- setTimer ( imageOff, 10000, 1 ) end addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), imageFunc) -- function imageOff () -- guiSetVisible ( image, false ) -- end -- function changePw() createPasswordWindow() guiSetVisible(windowpw, true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(username) local password = guiGetText(password) if username and password then triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Enter username and password.") end end end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(username) local password = guiGetText(password) if username and password then triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Enter username and password.") end end end function clientSubmitChangepw(button, state) if button == "left" and state == "up" then local oldpassword = guiGetText(usernamepw) local newpassword = guiGetText(passwordpw) if oldpassword and newpassword then triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword) else outputChatBox("Enter old and new password.") end end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(window, false) showCursor(false) guiSetVisible ( image, false ) end function hidePasswordWindow() guiSetInputEnabled(false) guiSetVisible(windowpw, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "Error 1: Please use /report") end function loginWrong() guiSetText(labelInfo, "Error 2: Bad password") end function registerTaken() guiSetText(labelInfo, "Error 3: This username already exist") end addEvent("hidePasswordWindow", true) addEvent("hideLoginWindow", true) addEvent("unknownError", true) addEvent("loginWrong", true) addEvent("registerTaken", true) addEventHandler("hidePasswordWindow", getRootElement(), hidePasswordWindow) addEventHandler("hideLoginWindow", getRootElement(), hideLoginWindow) addEventHandler("unknownError", getRootElement(), unknownError) addEventHandler("loginWrong", getRootElement(), loginWrong) addEventHandler("registerTaken", getRootElement(), registerTaken) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), resourceStart) addCommandHandler("changepw", changePw) Link to comment
MTA Team 0xCiBeR Posted January 14, 2014 MTA Team Share Posted January 14, 2014 Podrias probar cambiar los eventos. Link to comment
PhantomDamn Posted January 14, 2014 Author Share Posted January 14, 2014 (edited) podrias decirme algunos posibles? ----- el login tiene una imagen estatica de fondo que tapa toda la pantalla y es negra pero el spawn usa una camara matrix que no deja mostrar la imagen. Edited January 14, 2014 by Guest Link to comment
Alexs Posted January 14, 2014 Share Posted January 14, 2014 Lo que debes hacer es usar 'guiSetVisible' para hacer que el panel de spawn no se vea y en cuanto el jugador se loggee, lo haces visible. Link to comment
PhantomDamn Posted January 14, 2014 Author Share Posted January 14, 2014 osea que esto lo agrego al spawn y no al login? Link to comment
Sergioks Posted January 16, 2014 Share Posted January 16, 2014 Debes Colocar en el Spawn.. algo asi en la function: function windowLogin() guiSetVisible ( nombredeVentana, false ) end y cuando se logee con el Panel Login Que Hiciste, Que Aparezca la Gui del Spawn. Podrias Usar un Evento Asi: addEventHandler('onPlayerLogin', resourceRoot, function () guiSetVisible ( nombredeventana, true ) end ) Si Son Varias Ventanas tu Spawn, Pones Los guiSetVisibles en el eventHandler y ya. OJO: Soy Algo Nuevo en Scripting, asi pienzo yo que seria. Link to comment
MTA Team 0xCiBeR Posted January 17, 2014 MTA Team Share Posted January 17, 2014 Debes Colocar en el Spawn.. algo asi en la function: function windowLogin() guiSetVisible ( nombredeVentana, false ) end y cuando se logee con el Panel Login Que Hiciste, Que Aparezca la Gui del Spawn. Podrias Usar un Evento Asi: addEventHandler('onPlayerLogin', resourceRoot, function () guiSetVisible ( nombredeventana, true ) end ) Si Son Varias Ventanas tu Spawn, Pones Los guiSetVisibles en el eventHandler y ya. OJO: Soy Algo Nuevo en Scripting, asi pienzo yo que seria. Lo que te dice sergio es correcto, al menos asi lo haria yo..Aunque revisa los argumentos del: addEventHandler('onPlayerLogin', resourceRoot, function () guiSetVisible ( nombredeventana, true ) end ) Porque no son correctos. Link to comment
BorderLine Posted January 20, 2014 Share Posted January 20, 2014 Eso es imposible, estas usando un evento serverside con funciones clientside Usa triggers o bien que se ejecute guiSetVisible al darle al boton "Login" o el que sea Link to comment
MTA Team 0xCiBeR Posted January 20, 2014 MTA Team Share Posted January 20, 2014 (edited) Para que usar triggers? ._. Es tan simple como esto: addEventHandler( "onClientResourceStart", getRootElement( ), function () guiSetVisible ( nombredeventana, true ) end ) Además no entendiste su pregunta, el quiere ocultar el spawn, en cuanto entra al server, no despues de que se logueo. Lo que si, debe trigearlo es para volver a mostrar el spawn. Edited January 20, 2014 by Guest Link to comment
Alexs Posted January 20, 2014 Share Posted January 20, 2014 addEventHandler( "onClientResourceStart", getRootElement( ), function () guiSetVisible ( nombredeventana, true ) end ) Para que usar triggers? ._. Desde client-side no puedes detectar si un jugador se loggea y según veo, el quiere que el panel de spawn aparezca luego de que el jugador se loggee para que no aparezca un panel sobre el otro. Link to comment
MTA Team 0xCiBeR Posted January 20, 2014 MTA Team Share Posted January 20, 2014 pero el spawn queda montado sobre el login y la idea es que el login aparesca solo cuando un player entra Lo que el quiere, es que no se le superpongan el login y el panel. Es algo a lo que me pasaba a mi cuando usaba el spawn de 50p. Entonces, debe ocultarlo en cuanto empieze el resource, y luego mostrarlo en cuanto se loguea. Link to comment
PhantomDamn Posted January 20, 2014 Author Share Posted January 20, 2014 Exacto, hay dos GUI y ambas aparecen al mismo tiempo, Pero el login aparece primero, le he agregado imagenes estaticas y usado guiSetVisible y no he podido... mis players loguean en f8 ya que el spawn no lo permite ------------------- Ya solucione el problema, edite unas cosas del spawn y mas unas lineas que me envio alexs. Link to comment
Recommended Posts