+Sommer Posted February 3, 2021 Share Posted February 3, 2021 Eae rapaziada, tava fazendo um painel de login aqui e ele ta todo funcional já, só que tem um probleminha que ta tenso, não to conseguindo achar onde está errado. ---------- client.lua ---------- local sW, sH = guiGetScreenSize() loadstring(exports.dgs:dgsImportFunction())() DGS = { e = {} } color = {} addEventHandler("onClientResourceStart", resourceRoot, function() DGS.e[1] = dgsCreateEdit(0.42, 0.47, 0.16, 0.04, "", true) dgsSetAlpha(DGS.e[1], 0.75) dgsSetProperty(DGS.e[1], "NormalTextColour", "FE000000") dgsSetProperty(DGS.e[1], "font", "default-bold") DGS.e[2] = dgsCreateEdit(0.42, 0.55, 0.16, 0.04, "", true) dgsSetAlpha(DGS.e[2], 0.75) dgsSetProperty(DGS.e[2], "NormalTextColour", "FE000000") dgsSetProperty(DGS.e[2], "font", "default-bold") end) function dxLogin() dxDrawRectangle(sW * 0.3806, sH * 0.2167, sW * 0.2396, sH * 0.5678, tocolor(25, 30, 40, 160), false) dxDrawRectangle(sW * 0.3806, sH * 0.2156, sW * 0.2396, sH * 0.0833, tocolor(25, 40, 100, 100), false) dxDrawText("ATLANTIC © 2021", sW * 0.3806, sH * 0.2156, sW * 0.6201, sH * 0.2978, tocolor(200, 200, 200, 255), 2.00, "default-bold", "center", "center", false, false, false, false, false) dxDrawRectangle(sW * 0.3806, sH * 0.2989, sW * 0.2396, sH * 0.0044, tocolor(0, 0, 0, 180), false) color[1] = tocolor(200, 200, 200, 255) if cursorOnPosition(sW * 0.3875, sH * 0.6778, sW * 0.1042, sH * 0.0956) then color[1] = tocolor(0, 255, 0, 255) end dxDrawRectangle(sW * 0.3875, sH * 0.6778, sW * 0.1042, sH * 0.0956, tocolor(70, 75, 83, 175), false) -- Botão login color[2] = tocolor(200, 200, 200, 255) if cursorOnPosition(sW * 0.5090, sH * 0.6778, sW * 0.1042, sH * 0.0956) then color[2] = tocolor(255, 0, 0, 255) end dxDrawRectangle(sW * 0.5090, sH * 0.6778, sW * 0.1042, sH * 0.0956, tocolor(70, 75, 83, 175), false) -- Botão register dxDrawText("USER :", sW * 0.4229, sH * 0.4267, sW * 0.5035, sH * 0.4611, tocolor(155, 155, 155, 200), 1.00, "default-bold", "left", "bottom", false, false, false, false, false) dxDrawText("REGISTER :", sW * 0.4229, sH * 0.5100, sW * 0.5035, sH * 0.5444, tocolor(155, 155, 155, 200), 1.00, "default-bold", "left", "bottom", false, false, false, false, false) dxDrawText("Login", sW * 0.3875, sH * 0.6778, sW * 0.4917, sH * 0.7733, color[1], 1.20, "default-bold", "center", "center", false, false, false, false, false) dxDrawText("Create Account", sW * 0.5090, sH * 0.6778, sW * 0.6132, sH * 0.7733, color[2], 1.20, "default-bold", "center", "center", false, false, false, false, false) showCursor(true) addEventHandler('onClientClick', root, function(btn, state) if btn == 'left' and state == 'down' then if cursorOnPosition(sW * 0.3875, sH * 0.6778, sW * 0.1042, sH * 0.0956) then local g_user, g_pass = dgsGetText(DGS.e[1]), dgsGetText(DGS.e[2]) triggerServerEvent('playerRequestLog', getLocalPlayer(), g_user, g_pass) end end end) end addEventHandler('onClientRender', root, dxLogin) addEvent('playerLogged', true) function playerLogged() removeEventHandler('onClientRender', root, dxLogin) destroyElement(DGS.e[1]) destroyElement(DGS.e[2]) showCursor(false) end addEventHandler('playerLogged', getRootElement(), playerLogged) addEvent('playerRegisterSucess', true) function playerRegisterSucess() destroyElement(GUI.window[2]) end addEventHandler('playerRegisterSucess', getRootElement(), playerLogged) function cursorOnPosition(x, y, w, h) if (not isCursorShowing()) then return false end local mx, my = getCursorPosition() local sx, sy = guiGetScreenSize() local cx, cy = (mx*sx), (my*sy) if (cx > x and cx < x + w) and (cy > y and cy < y + h) then return true else return false end end Creio que seja no client mas, vou colocar aqui o lado server tbm: ---------- server.lua ---------- addEvent('playerRequestLog', true) function playerRequestLog(user, pass) if not(user == '') then if not(pass == '') then local account = getAccount(user, pass) if not account then outputChatBox('ERROR: Está conta não existe.', source, 255, 0, 0) else logIn(source, account, pass) triggerClientEvent(source, 'playerLogged', source) outputChatBox('Logado com sucesso. =)', source, 0, 255, 255) end else outputChatBox('Insira uma senha.', source, 255, 0, 0) end else outputChatBox('Insira um username.', source, 255, 0, 0) end end addEventHandler('playerRequestLog', getRootElement(), playerRequestLog) addEvent('playerRequestRegister', true) function playerRequestRegister(reguser, regpass) if not(reguser == '') then if not(regpass == '') then local account = getAccount(reguser, regpass) if (account) then outputChatBox('ERROR: Está conta já existe, insira outro username e senha.', source, 255, 0, 0) else addAccount(reguser, regpass) outputChatBox('Registrado com sucesso, faça o login agora.', source, 0, 255, 255) triggerClientEvent(source, 'playerRegisterSucess', source) end else outputChatBox('Insira uma senha.', source, 255, 0, 0) end else outputChatBox('Insira um username.', source, 255, 0, 0) end end addEventHandler('playerRequestRegister', getRootElement(), playerRequestRegister) O Erro é o seguinte, quando o player não digitar um campo, ou a não existir ele emite um texto no chat(futuramente farei menssagens, é só para teste), só que ta repetindo as frases e muito papo de floodar o chat da um ligo: https://imgur.com/a/S3qPhVk Se poderem me ajudar ai fico grato s2 Link to comment
Administrators Tut Posted February 3, 2021 Administrators Share Posted February 3, 2021 Thread's been moved into the Portuguese programming section Link to comment
XXII Posted February 3, 2021 Share Posted February 3, 2021 Você está adicionando o evento onClientClick dentro da função que é ativada com onClientRender Apenas adicione-o fora desta função 1 Link to comment
+Sommer Posted February 4, 2021 Author Share Posted February 4, 2021 9 hours ago, SousaSRC said: Você está adicionando o evento onClientClick dentro da função que é ativada com onClientRender Apenas adicione-o fora desta função Ih alaa, parou vlw mesmo ^^ 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