Flipi Posted October 3, 2013 Share Posted October 3, 2013 How do I run the guest button added to the script of the community (login panel)? the button not work... (I added button guest) (the button is called "invitado") Client... local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(255, 255, 255, 255), 0.5, "bankgothic", "center", "top", false, false, false, false, false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+276, pY+168, pX+276, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.inv.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(r, g, b, data.inv.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.inv.hovering ) then data.inv.colors = { 0, 128, 255 } local alpha = data.inv.loginTextAlpha if ( not data.inv.alphaMode ) then data.inv.loginTextAlpha = alpha - 5 if ( data.inv.loginTextAlpha <= 50 ) then data.inv.alphaMode = true end else data.inv.loginTextAlpha = alpha + 5 if ( data.inv.loginTextAlpha >= 235 ) then data.inv.alphaMode = false end end data.login.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.inv.lognTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } data.inv.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then data.login.hovering = true return elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then data.reg.hovering = true return elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then data.inv.hovering = true end end end data.login.hovering = false data.reg.hovering = false data.inv.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end end end end -- invitado boton elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then if function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) Server... local cameras = { { 329.10980224609, -2117.2749023438, 50.161201477051, 329.65179443359, -2116.4926757813, 49.853763580322 }, { 1266.0053710938, -1965.7087402344, 114.59829711914, 1265.1549072266, -1966.1115722656, 114.25980377197 }, { 1514.0283203125, -1716.5743408203, 39.910701751709, 1514.5087890625, -1715.865234375, 39.394691467285 }, { 1338.7514648438, -875.66558837891, 99.84880065918, 1339.4935302734, -875.07824707031, 99.52579498291 }, { 1426.5421142578, -725.40289306641, 120.97090148926, 1427.3695068359, -725.00805664063, 120.571434021 }, { 1357.5914306641, -592.23327636719, 125.15190124512, 1357.1751708984, -593.02673339844, 124.70780944824 }, { 988.01123046875, -341.88409423828, 74.752601623535, 988.70251464844, -342.45135498047, 75.200187683105 }, { -224.32290649414, -153.71020507813, 35.085899353027, -223.61195373535, -153.04695129395, 34.852146148682 } } function openView( plr ) local theplr = nil if ( source and getElementType ( source ) == 'player' ) then theplr = source elseif ( plr and getElementType ( plr ) == 'player' ) then theplr = plr end setTimer ( function ( p ) local ind = math.random ( #cameras ) setCameraMatrix ( p, unpack ( cameras[ind] ) ) end, 700, 1, theplr ) end addEventHandler ( "onPlayerJoin", root, openView ) addEventHandler ( "onPlayerLogout", root, openView ) --addCommandHandler ( 'view', openView ) function attemptLogin ( user, pass ) if ( user and pass and type ( user ) == 'string' and type ( pass ) == 'string' ) then --local user = string.lower ( user ) --local pass = string.lower ( pass ) local account = getAccount ( user ) if ( account ) then if ( not logIn ( source, account, pass ) ) then message ( source, "Password incorrecta \npor favor verifique." ) return false end setCameraTarget ( source, source ) triggerLogin ( source, user, pass ) else message ( source, "Cuenta desconocida \npor favor verifique." ) return false end end return false end addEvent ( "Login:onClientAttemptLogin", true ) addEventHandler ( "Login:onClientAttemptLogin", root, attemptLogin ) function attemptRegister ( user, pass ) if ( user and pass and type ( user ) == 'string' and type ( pass ) == 'string' ) then --local user = string.lower ( user ) --local pass = string.lower ( pass ) local account = getAccount ( user ) if ( not account ) then local account = addAccount ( user, pass ) if ( account ) then if ( not logIn ( source, account, pass ) ) then return message ( source, "Ocurrio un error en el logeo." ) end setCameraTarget ( source, source ) triggerLogin ( source, user, pass ) else message ( source, "Error al registrar la cuenta. \nPor favor contacta con un Admin." ) end else message ( source, "Esta cuenta ya existe." ) end end return false end addEvent ( "Login:onClientAttemptRegistration", true ) addEventHandler ( "Login:onClientAttemptRegistration", root, attemptRegister ) function message ( source, msg ) triggerClientEvent ( source, "onPlayerLoginPanelError", source, msg ) end function triggerLogin ( source, user, pass ) triggerClientEvent ( source, "onClientPlayerLogin", source, user, pass ) end addEventHandler ( 'onPlayerLogout', root, function ( ) triggerClientEvent ( source, 'onClientPlayerLogout', source ) end ) Link to comment
Chopper Posted October 4, 2013 Share Posted October 4, 2013 What i'd do is: local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) inviteButton = dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(255, 255, 255, 255), 0.5, "bankgothic", "center", "top", false, false, false, false, false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+276, pY+168, pX+276, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.inv.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(r, g, b, data.inv.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.inv.hovering ) then data.inv.colors = { 0, 128, 255 } local alpha = data.inv.loginTextAlpha if ( not data.inv.alphaMode ) then data.inv.loginTextAlpha = alpha - 5 if ( data.inv.loginTextAlpha <= 50 ) then data.inv.alphaMode = true end else data.inv.loginTextAlpha = alpha + 5 if ( data.inv.loginTextAlpha >= 235 ) then data.inv.alphaMode = false end end data.login.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.inv.lognTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } data.inv.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then data.login.hovering = true return elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then data.reg.hovering = true return elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then data.inv.hovering = true end end end data.login.hovering = false data.reg.hovering = false data.inv.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end end end end -- invitado boton elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then if function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) function attachedFunct() --the code here that you want to attach to the button. end addEventHandler("onClientGUIClick", invitebutton, attachedFunct, false) Not sure if it will work, didnt test. Link to comment
Flipi Posted October 4, 2013 Author Share Posted October 4, 2013 What i'd do is: local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) inviteButton = dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(255, 255, 255, 255), 0.5, "bankgothic", "center", "top", false, false, false, false, false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+276, pY+168, pX+276, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.inv.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(r, g, b, data.inv.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.inv.hovering ) then data.inv.colors = { 0, 128, 255 } local alpha = data.inv.loginTextAlpha if ( not data.inv.alphaMode ) then data.inv.loginTextAlpha = alpha - 5 if ( data.inv.loginTextAlpha <= 50 ) then data.inv.alphaMode = true end else data.inv.loginTextAlpha = alpha + 5 if ( data.inv.loginTextAlpha >= 235 ) then data.inv.alphaMode = false end end data.login.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.inv.lognTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } data.inv.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then data.login.hovering = true return elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then data.reg.hovering = true return elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then data.inv.hovering = true end end end data.login.hovering = false data.reg.hovering = false data.inv.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end end end end -- invitado boton elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then if function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) function attachedFunct() --the code here that you want to attach to the button. end addEventHandler("onClientGUIClick", invitebutton, attachedFunct, false) Not sure if it will work, didnt test. I fail to make it work, I can not do guest function Link to comment
Moderators Citizen Posted October 5, 2013 Moderators Share Posted October 5, 2013 Ok just copy and paste this: Client: local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } data.login.hovering = false data.reg.hovering = false data.inv.hovering = false function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(255, 255, 255, 255), 0.5, "bankgothic", "center", "top", false, false, false, false, false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+276, pY+168, pX+276, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.inv.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(r, g, b, data.inv.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.inv.hovering ) then data.inv.colors = { 0, 128, 255 } local alpha = data.inv.loginTextAlpha if ( not data.inv.alphaMode ) then data.inv.loginTextAlpha = alpha - 5 if ( data.inv.loginTextAlpha <= 50 ) then data.inv.alphaMode = true end else data.inv.loginTextAlpha = alpha + 5 if ( data.inv.loginTextAlpha >= 235 ) then data.inv.alphaMode = false end end data.login.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.inv.lognTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } data.inv.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then data.login.hovering = true elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then data.reg.hovering = true elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then data.inv.hovering = true end end end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- invitado boton elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then outputChatBox( "I clicked on invitado button !") triggerServerEvent( "Login:onClientAttemptGuest", localPlayer ) end end end function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) Server: local cameras = { { 329.10980224609, -2117.2749023438, 50.161201477051, 329.65179443359, -2116.4926757813, 49.853763580322 }, { 1266.0053710938, -1965.7087402344, 114.59829711914, 1265.1549072266, -1966.1115722656, 114.25980377197 }, { 1514.0283203125, -1716.5743408203, 39.910701751709, 1514.5087890625, -1715.865234375, 39.394691467285 }, { 1338.7514648438, -875.66558837891, 99.84880065918, 1339.4935302734, -875.07824707031, 99.52579498291 }, { 1426.5421142578, -725.40289306641, 120.97090148926, 1427.3695068359, -725.00805664063, 120.571434021 }, { 1357.5914306641, -592.23327636719, 125.15190124512, 1357.1751708984, -593.02673339844, 124.70780944824 }, { 988.01123046875, -341.88409423828, 74.752601623535, 988.70251464844, -342.45135498047, 75.200187683105 }, { -224.32290649414, -153.71020507813, 35.085899353027, -223.61195373535, -153.04695129395, 34.852146148682 } } function openView( plr ) local theplr = nil if ( source and getElementType ( source ) == 'player' ) then theplr = source elseif ( plr and getElementType ( plr ) == 'player' ) then theplr = plr end setTimer ( function ( p ) local ind = math.random ( #cameras ) setCameraMatrix ( p, unpack ( cameras[ind] ) ) end, 700, 1, theplr ) end addEventHandler ( "onPlayerJoin", root, openView ) addEventHandler ( "onPlayerLogout", root, openView ) --addCommandHandler ( 'view', openView ) function attemptLogin ( user, pass ) if ( user and pass and type ( user ) == 'string' and type ( pass ) == 'string' ) then --local user = string.lower ( user ) --local pass = string.lower ( pass ) local account = getAccount ( user ) if ( account ) then if ( not logIn ( source, account, pass ) ) then message ( source, "Password incorrecta \npor favor verifique." ) return false end setCameraTarget ( source, source ) triggerLogin ( source, user, pass ) else message ( source, "Cuenta desconocida \npor favor verifique." ) return false end end return false end addEvent ( "Login:onClientAttemptLogin", true ) addEventHandler ( "Login:onClientAttemptLogin", root, attemptLogin ) function attemptRegister ( user, pass ) if ( user and pass and type ( user ) == 'string' and type ( pass ) == 'string' ) then --local user = string.lower ( user ) --local pass = string.lower ( pass ) local account = getAccount ( user ) if ( not account ) then local account = addAccount ( user, pass ) if ( account ) then if ( not logIn ( source, account, pass ) ) then return message ( source, "Ocurrio un error en el logeo." ) end setCameraTarget ( source, source ) triggerLogin ( source, user, pass ) else message ( source, "Error al registrar la cuenta. \nPor favor contacta con un Admin." ) end else message ( source, "Esta cuenta ya existe." ) end end return false end addEvent ( "Login:onClientAttemptRegistration", true ) addEventHandler ( "Login:onClientAttemptRegistration", root, attemptRegister ) function message ( source, msg ) triggerClientEvent ( source, "onPlayerLoginPanelError", source, msg ) end function triggerLogin ( source, user, pass ) triggerClientEvent ( source, "onClientPlayerLogin", source, user, pass ) end addEventHandler ( 'onPlayerLogout', root, function ( ) triggerClientEvent ( source, 'onClientPlayerLogout', source ) end ) addEvent( "Login:onClientAttemptGuest", true ) function attemptGuest() local pname = tostring(getPlayerName(source)) outputChatBox("Serverside: Logging "..source.." as guest !") -- Do your stuff here end addEventHandler( "Login:onClientAttemptGuest", root, attemptGuest) You definitly should use a correct text editor with syntax highlighting (for example Notepad++). There were some codes that were out of functions that you probably wanted put in them. Best regards, Citizen Link to comment
Flipi Posted October 5, 2013 Author Share Posted October 5, 2013 Ok just copy and paste this:Client: local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } data.login.hovering = false data.reg.hovering = false data.inv.hovering = false function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(255, 255, 255, 255), 0.5, "bankgothic", "center", "top", false, false, false, false, false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+276, pY+168, pX+276, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.inv.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor(r, g, b, data.inv.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.inv.hovering ) then data.inv.colors = { 0, 128, 255 } local alpha = data.inv.loginTextAlpha if ( not data.inv.alphaMode ) then data.inv.loginTextAlpha = alpha - 5 if ( data.inv.loginTextAlpha <= 50 ) then data.inv.alphaMode = true end else data.inv.loginTextAlpha = alpha + 5 if ( data.inv.loginTextAlpha >= 235 ) then data.inv.alphaMode = false end end data.login.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.inv.lognTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } data.inv.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then data.login.hovering = true elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then data.reg.hovering = true elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then data.inv.hovering = true end end end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 and y >= pY+170 and y <= pY+200 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( y >= pY+170 and y <= pY+200 and x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- invitado boton elseif ( x >= pX+105 and x <= pX+195 and y >= pY+230 and y <= pY+260 ) then outputChatBox( "I clicked on invitado button !") triggerServerEvent( "Login:onClientAttemptGuest", localPlayer ) end end end function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) Server: local cameras = { { 329.10980224609, -2117.2749023438, 50.161201477051, 329.65179443359, -2116.4926757813, 49.853763580322 }, { 1266.0053710938, -1965.7087402344, 114.59829711914, 1265.1549072266, -1966.1115722656, 114.25980377197 }, { 1514.0283203125, -1716.5743408203, 39.910701751709, 1514.5087890625, -1715.865234375, 39.394691467285 }, { 1338.7514648438, -875.66558837891, 99.84880065918, 1339.4935302734, -875.07824707031, 99.52579498291 }, { 1426.5421142578, -725.40289306641, 120.97090148926, 1427.3695068359, -725.00805664063, 120.571434021 }, { 1357.5914306641, -592.23327636719, 125.15190124512, 1357.1751708984, -593.02673339844, 124.70780944824 }, { 988.01123046875, -341.88409423828, 74.752601623535, 988.70251464844, -342.45135498047, 75.200187683105 }, { -224.32290649414, -153.71020507813, 35.085899353027, -223.61195373535, -153.04695129395, 34.852146148682 } } function openView( plr ) local theplr = nil if ( source and getElementType ( source ) == 'player' ) then theplr = source elseif ( plr and getElementType ( plr ) == 'player' ) then theplr = plr end setTimer ( function ( p ) local ind = math.random ( #cameras ) setCameraMatrix ( p, unpack ( cameras[ind] ) ) end, 700, 1, theplr ) end addEventHandler ( "onPlayerJoin", root, openView ) addEventHandler ( "onPlayerLogout", root, openView ) --addCommandHandler ( 'view', openView ) function attemptLogin ( user, pass ) if ( user and pass and type ( user ) == 'string' and type ( pass ) == 'string' ) then --local user = string.lower ( user ) --local pass = string.lower ( pass ) local account = getAccount ( user ) if ( account ) then if ( not logIn ( source, account, pass ) ) then message ( source, "Password incorrecta \npor favor verifique." ) return false end setCameraTarget ( source, source ) triggerLogin ( source, user, pass ) else message ( source, "Cuenta desconocida \npor favor verifique." ) return false end end return false end addEvent ( "Login:onClientAttemptLogin", true ) addEventHandler ( "Login:onClientAttemptLogin", root, attemptLogin ) function attemptRegister ( user, pass ) if ( user and pass and type ( user ) == 'string' and type ( pass ) == 'string' ) then --local user = string.lower ( user ) --local pass = string.lower ( pass ) local account = getAccount ( user ) if ( not account ) then local account = addAccount ( user, pass ) if ( account ) then if ( not logIn ( source, account, pass ) ) then return message ( source, "Ocurrio un error en el logeo." ) end setCameraTarget ( source, source ) triggerLogin ( source, user, pass ) else message ( source, "Error al registrar la cuenta. \nPor favor contacta con un Admin." ) end else message ( source, "Esta cuenta ya existe." ) end end return false end addEvent ( "Login:onClientAttemptRegistration", true ) addEventHandler ( "Login:onClientAttemptRegistration", root, attemptRegister ) function message ( source, msg ) triggerClientEvent ( source, "onPlayerLoginPanelError", source, msg ) end function triggerLogin ( source, user, pass ) triggerClientEvent ( source, "onClientPlayerLogin", source, user, pass ) end addEventHandler ( 'onPlayerLogout', root, function ( ) triggerClientEvent ( source, 'onClientPlayerLogout', source ) end ) addEvent( "Login:onClientAttemptGuest", true ) function attemptGuest() local pname = tostring(getPlayerName(source)) outputChatBox("Serverside: Logging "..source.." as guest !") -- Do your stuff here end addEventHandler( "Login:onClientAttemptGuest", root, attemptGuest) You definitly should use a correct text editor with syntax highlighting (for example Notepad++). There were some codes that were out of functions that you probably wanted put in them. Best regards, Citizen But what in the event of a guest on serverside as I do? (I've never changed or created a login panel) Link to comment
xXMADEXx Posted October 5, 2013 Share Posted October 5, 2013 It'd be nice if you kept my credits on the script... No need to continue this topic. Im making guest mode for the login panel now. Edit: I added the guest button. https://community.multitheftauto.com/index.php?p= ... ls&id=7970 Link to comment
Flipi Posted October 6, 2013 Author Share Posted October 6, 2013 (edited) It'd be nice if you kept my credits on the script...No need to continue this topic. Im making guest mode for the login panel now. Edit: I added the guest button. https://community.multitheftauto.com/index.php?p= ... ls&id=7970 how I can modify it as well?, I did well, but I have bad button... (the button is called "invitado") Screen 1: http://imageshack.us/a/img692/6351/pti2.png Screen 2: http://imageshack.us/a/img855/679/lkro.png Client... local enableGuest = true; local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, guest = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+281, pY+168, pX+281, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) if ( enableGuest ) then local r, g, b = unpack ( data.guest.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor( r, g, b, data.guest.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) end -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.guest.hovering ) then data.guest.colors = { 0, 128, 255 } local alpha = data.guest.loginTextAlpha if ( not data.guest.alphaMode ) then data.guest.loginTextAlpha = alpha - 5 if ( data.guest.loginTextAlpha <= 50 ) then data.guest.alphaMode = true end else data.guest.loginTextAlpha = alpha + 5 if ( data.guest.loginTextAlpha >= 235 ) then data.guest.alphaMode = false end end else data.login.loginTextAlpha = 235 data.guest.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.guest.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( y >= pY+170 and y <= pY+200 ) then if ( x >= pX+161 and x <= pX+251 ) then data.login.hovering = true return elseif ( x >= pX+305 and x <= pX+445 ) then data.reg.hovering = true return elseif ( y <= pY+15 and y >= pY+91 ) then elseif ( x >= pX+10 and x <= pX+91 ) then data.guest.hovering = true return end end end data.login.hovering = false data.reg.hovering = false data.guest.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then if ( y >= pY+170 and y <= pY+200 ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- play as guest elseif ( x >= pX+10 and x <= pX+91 ) then closeLogin ( ) triggerServerEvent ( "Login:doClientGuestLogin", localPlayer ) end end end end function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) Edited October 6, 2013 by Guest Link to comment
xXMADEXx Posted October 6, 2013 Share Posted October 6, 2013 It'd be nice if you kept my credits on the script...No need to continue this topic. Im making guest mode for the login panel now. Edit: I added the guest button. https://community.multitheftauto.com/index.php?p= ... ls&id=7970 how I can modify it as well?, I did well, but I have bad button... (the button is called "invitado") Screen 1: http://imageshack.us/a/img692/6351/pti2.png Screen 2: http://imageshack.us/a/img692/6351/pti2.png Client... local enableGuest = true; local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, guest = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+281, pY+168, pX+281, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) if ( enableGuest ) then local r, g, b = unpack ( data.guest.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor( r, g, b, data.guest.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) end -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.guest.hovering ) then data.guest.colors = { 0, 128, 255 } local alpha = data.guest.loginTextAlpha if ( not data.guest.alphaMode ) then data.guest.loginTextAlpha = alpha - 5 if ( data.guest.loginTextAlpha <= 50 ) then data.guest.alphaMode = true end else data.guest.loginTextAlpha = alpha + 5 if ( data.guest.loginTextAlpha >= 235 ) then data.guest.alphaMode = false end end else data.login.loginTextAlpha = 235 data.guest.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.guest.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( y >= pY+170 and y <= pY+200 ) then if ( x >= pX+161 and x <= pX+251 ) then data.login.hovering = true return elseif ( x >= pX+305 and x <= pX+445 ) then data.reg.hovering = true return elseif ( y <= pY+15 and y >= pY+91 ) then elseif ( x >= pX+10 and x <= pX+91 ) then data.guest.hovering = true return end end end data.login.hovering = false data.reg.hovering = false data.guest.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then if ( y >= pY+170 and y <= pY+200 ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- play as guest elseif ( x >= pX+10 and x <= pX+91 ) then closeLogin ( ) triggerServerEvent ( "Login:doClientGuestLogin", localPlayer ) end end end end function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) What do you mean..? Link to comment
Flipi Posted October 6, 2013 Author Share Posted October 6, 2013 It'd be nice if you kept my credits on the script...No need to continue this topic. Im making guest mode for the login panel now. Edit: I added the guest button. https://community.multitheftauto.com/index.php?p= ... ls&id=7970 how I can modify it as well?, I did well, but I have bad button... (the button is called "invitado") Screen 1: http://imageshack.us/a/img692/6351/pti2.png Screen 2: http://imageshack.us/a/img692/6351/pti2.png Client... local enableGuest = true; local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, guest = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+281, pY+168, pX+281, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) if ( enableGuest ) then local r, g, b = unpack ( data.guest.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor( r, g, b, data.guest.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) end -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.guest.hovering ) then data.guest.colors = { 0, 128, 255 } local alpha = data.guest.loginTextAlpha if ( not data.guest.alphaMode ) then data.guest.loginTextAlpha = alpha - 5 if ( data.guest.loginTextAlpha <= 50 ) then data.guest.alphaMode = true end else data.guest.loginTextAlpha = alpha + 5 if ( data.guest.loginTextAlpha >= 235 ) then data.guest.alphaMode = false end end else data.login.loginTextAlpha = 235 data.guest.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.guest.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( y >= pY+170 and y <= pY+200 ) then if ( x >= pX+161 and x <= pX+251 ) then data.login.hovering = true return elseif ( x >= pX+305 and x <= pX+445 ) then data.reg.hovering = true return elseif ( y <= pY+15 and y >= pY+91 ) then elseif ( x >= pX+10 and x <= pX+91 ) then data.guest.hovering = true return end end end data.login.hovering = false data.reg.hovering = false data.guest.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then if ( y >= pY+170 and y <= pY+200 ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- play as guest elseif ( x >= pX+10 and x <= pX+91 ) then closeLogin ( ) triggerServerEvent ( "Login:doClientGuestLogin", localPlayer ) end end end end function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) What do you mean..? I want to put the button like in the screens, but can no do it.. see the screens I modified a link was wrong (screens) Link to comment
xXMADEXx Posted October 7, 2013 Share Posted October 7, 2013 so what button are you trying to modify? The Login/Register button or the guest button? Link to comment
Flipi Posted October 7, 2013 Author Share Posted October 7, 2013 so what button are you trying to modify? The Login/Register button or the guest button? the guest button (invitado), see the images: "I put the guest button else low, but not working properly" image1: http://imageshack.us/a/img855/679/lkro.png image2: http://imageshack.us/a/img692/6351/pti2.png local enableGuest = true; local sx, sy = guiGetScreenSize ( ) local pX, pY = ( sx / 2 - 485 / 2 ), ( sy / 2 - 231 / 2 ) local username = guiCreateEdit(pX+156, pY+61, 288, 33, "", false) guiSetVisible ( username, false ) local password = guiCreateEdit(pX+156, pY+121, 288, 33, "", false) guiSetVisible ( password, false ) guiEditSetMasked(password, true) local window = guiCreateWindow( ( sx / 2 - 266 / 2 ), ( sy / 2 - 208 / 2 ), 266, 208, "Error", false) guiWindowSetMovable(window, false) guiWindowSetSizable(window, false) guiSetVisible ( window, false ) guiSetAlpha ( window, 1 ) local exitBtn = guiCreateButton(155, 162, 101, 36, "Salir", false, window) local infoLbl = guiCreateLabel(18, 26, 228, 130, "Mensaje", false, window) local isOpen = false; local isLoggedin = false; local data = { login = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, reg = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } }, guest = { hovering = false, alphaMode = false, loginTextAlpha = 235, colors = { 255, 255, 255 } } } function dxDrawLoginPanel( ) -- default: 350, 266 if ( isOpen ) then dxDrawRectangle(pX, pY, 485, 231, tocolor(0, 0, 0, 180), false) dxDrawRectangle(pX, pY+231, 100, 19, tocolor(0, 0, 0, 180), false) dxDrawText("Login", pX-220, pY, 870, 314, tocolor(0, 128, 255, 255), 1.50, "bankgothic", "center", "top", false, false, false, false, false) dxDrawLine(pX, pY+48, pX+485, pY+48, tocolor(255, 128, 0, 255), 1, false) dxDrawText("Usuario:", pX+10, pY+69, 506, 368, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText("Password:", pX+10, pY+129, 506, 428, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "left", "top", false, false, false, false, false) dxDrawLine(pX+281, pY+168, pX+281, pY+168+34, tocolor(255, 128, 0, 255), 1, false) local r, g, b = unpack ( data.login.colors ) dxDrawText("Login", pX+156, pY+167, 600, 468, tocolor( r, g, b, data.login.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) local r, g, b = unpack ( data.reg.colors ) dxDrawText("Register", pX+300, pY+167, 794, 468, tocolor(r, g, b, data.reg.loginTextAlpha), 1.00, "bankgothic", "left", "top", false, false, false, false, false) if ( enableGuest ) then local r, g, b = unpack ( data.guest.colors ) dxDrawText("Invitado", pX+105, pY+230, 150, 10, tocolor( r, g, b, data.guest.loginTextAlpha), 0.5, "bankgothic", "center", "top", false, false, false, false, false) end -- give fade effect if ( data.login.hovering ) then data.login.colors = { 0, 128, 255 } local alpha = data.login.loginTextAlpha if ( not data.login.alphaMode ) then data.login.loginTextAlpha = alpha - 5 if ( data.login.loginTextAlpha <= 50 ) then data.login.alphaMode = true end else data.login.loginTextAlpha = alpha + 5 if ( data.login.loginTextAlpha >= 235 ) then data.login.alphaMode = false end end elseif ( data.reg.hovering ) then data.reg.colors = { 0, 128, 255 } local alpha = data.reg.loginTextAlpha if ( not data.reg.alphaMode ) then data.reg.loginTextAlpha = alpha - 5 if ( data.reg.loginTextAlpha <= 50 ) then data.reg.alphaMode = true end else data.reg.loginTextAlpha = alpha + 5 if ( data.reg.loginTextAlpha >= 235 ) then data.reg.alphaMode = false end end elseif ( data.guest.hovering ) then data.guest.colors = { 0, 128, 255 } local alpha = data.guest.loginTextAlpha if ( not data.guest.alphaMode ) then data.guest.loginTextAlpha = alpha - 5 if ( data.guest.loginTextAlpha <= 50 ) then data.guest.alphaMode = true end else data.guest.loginTextAlpha = alpha + 5 if ( data.guest.loginTextAlpha >= 235 ) then data.guest.alphaMode = false end end else data.login.loginTextAlpha = 235 data.guest.loginTextAlpha = 235 data.reg.loginTextAlpha = 235 data.login.colors = { 255, 255, 255 } data.guest.colors = { 255, 255, 255 } data.reg.colors = { 255, 255, 255 } end end end function cursorMove ( _, _, x, y ) if ( isCursorShowing ( ) and not guiGetVisible ( window ) and isOpen) then if ( y >= pY+170 and y <= pY+200 ) then if ( x >= pX+161 and x <= pX+251 ) then data.login.hovering = true return elseif ( x >= pX+305 and x <= pX+445 ) then data.reg.hovering = true return elseif ( y <= pY+15 and y >= pY+91 ) then elseif ( x >= pX+10 and x <= pX+91 ) then data.guest.hovering = true return end end end data.login.hovering = false data.reg.hovering = false data.guest.hovering = false end function openLogin ( ) addEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) addEventHandler ( 'onClientCursorMove', root, cursorMove ) addEventHandler ( "onClientClick", root, clientClicking ) guiSetInputMode ( "no_binds_when_editing" ) guiSetVisible ( password, true ) guiSetVisible ( username, true ) showCursor ( true ) addEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) isOpen = true showChat(false) showPlayerHudComponent ( 'all', false ) end addEvent ( "onClientPlayerLogout", true ) addEventHandler ( 'onClientPlayerLogout', root, openLogin ) function closeLogin ( ) removeEventHandler ( "onClientPreRender", root, dxDrawLoginPanel ) removeEventHandler ( 'onClientCursorMove', root, cursorMove ) removeEventHandler ( "onClientClick", root, clientClicking ) guiSetVisible ( password, false ) guiSetVisible ( username, false ) showCursor ( false ) removeEventHandler ( 'onClientGUIClick', root, clientClosingErrorWindowEvent ) guiSetVisible ( window, false ) isOpen = false isLoggedin = true showChat(true) showPlayerHudComponent ( 'all', true ) end addEvent ( "onClientPlayerLogin", true ) addEventHandler ( "onClientPlayerLogin", root, closeLogin ) function sendError ( msg ) if ( not guiGetVisible ( window ) ) then guiSetVisible ( window, true ) guiSetText ( infoLbl, msg ) guiBringToFront ( window ) end end addEvent ( "onPlayerLoginPanelError", true ) addEventHandler ( "onPlayerLoginPanelError", root, sendError ) function clientClicking ( btn, state, x, y ) if ( btn == 'left' and not guiGetVisible ( window ) and state == 'down' and isOpen ) then if ( y >= pY+170 and y <= pY+200 ) then local user, pass = guiGetText ( username ), guiGetText ( password ) -- Login Button -- if ( x >= pX+156 and x <= pX+246 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "Los espacios (' ') no estan permitido \npara colocarlo en la password." ) end triggerServerEvent ( "Login:onClientAttemptLogin", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- register button elseif ( x >= pX+300 and x <= pX+440 ) then if ( string.gsub ( user, ' ', '' ) ~= '' and string.gsub ( pass, ' ', '' ) ~= '' ) then if ( string.find ( user, '%s' ) ) then return sendError ( "No se permiten espacios \nen el usuario." ) end if ( string.find ( pass, '%s' ) ) then return sendError ( "No se permiten espacios \nen la contraseña." ) end if ( string.len ( user ) < 5 ) then return sendError ( "El usuario debe tener \ncomo minimo 5 caracteres de largo." ) end if ( string.len ( pass ) < 6 ) then return sendError ( "La contraseña debe tener \ncomo mínimo 6 caracteres de largo." ) end triggerServerEvent ( "Login:onClientAttemptRegistration", localPlayer, user, pass ) else sendError ( "Un usuario y contraseña es requerido \npara ingresar al server..." ) end -- play as guest elseif ( x >= pX+10 and x <= pX+91 ) then closeLogin ( ) triggerServerEvent ( "Login:doClientGuestLogin", localPlayer ) end end end end function clientClosingErrorWindowEvent( ) if ( source == exitBtn ) then guiSetVisible ( window, false ) end end function isClientLoggedin ( ) return isLoggedin end setTimer ( function ( ) openLogin ( ) end, 700, 1 ) 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