Ganan229 Posted April 23, 2021 Share Posted April 23, 2021 addEventHandler("onClientKey", root, function (button, press) if getElementData(getLocalPlayer(),"LoginPainel") == true then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "b" or button == "F9" or button == "F10" or button == "F11" or button == "F12" then cancelEvent() end end end ) O painel de login que estou usando não é por ElementData. Então dessa maneira ele não ira bloquear as binds do teclado quando ela la na hora de fazer o login ou si registrar. eu fiz de uma outra maneira até funciona mas buga quando faço o login e clico qualquer tecla ele volta no painel de login que seria assim: addEventHandler("onClientKey", root, function (button, press) LoginPainel (true) if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "b" or button == "F9" or button == "F10" or button == "F11" or button == "F12" then cancelEvent() end end end ) Si tiver um outro tópico sobre isso me desculpem eu realmente não sabia. Mas si não houver. Alguém puder me ajudar como eu consigo bloquear as binds do teclado ira me ajudar muito mesmo. Desde já agradeço. Link to comment
Jonas^ Posted April 25, 2021 Share Posted April 25, 2021 Obviamente vai bugar, você esta chamando uma função que provavelmente é a que mostra o painel na sua segunda função. Mostre como esta seu client do painel de login pra gente ver. Link to comment
Ganan229 Posted April 26, 2021 Author Share Posted April 26, 2021 Eu estou colocando no Client. Devo colocar no server.? sw, sh = guiGetScreenSize () px = math.min( sw / 1920, 1 ) Login = {}; Login.Interface = {}; addEventHandler("onClientKey", root, function (button, press) LoginPainel (true) if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "b" or button == "F9" or button == "F10" or button == "F11" or button == "F12" then cancelEvent() end end end ) function Login.Interface:onRender() function Login.Interface:Startup() self.Weight = 562 * px; self.Height = 515 * px; self.PosX = ( sw / 2) - ( self.Weight / 2 ); self.PosY = ( sh / 2) - ( self.Height / 2 ); self.isVisible = false; self.medium = DxFont("assets/fonts/medium.ttf", 23*px); self.medium2 = DxFont("assets/fonts/medium.ttf", 21*px); self.medium3 = DxFont("assets/fonts/medium.ttf", 30*px); self.click = false self.edits = { login = "", password = "", loginReg = "", passwordReg = "", passwordRegRef = "", selection = 1, selected = nil, symbol = { [1] = "", [2] = "", [3] = "", [4] = "", [5] = "", }, timers = {}, }; Login.Color = { Standart = tocolor(142, 68, 69, 255); Hover = tocolor(142, 68, 69, 255); }; end; Login.Interface:Startup() function checkLine () if self.edits.selected then local i = self.edits.selected local s, e = string.find (self.edits.symbol[i], "|") if s == string.len(self.edits.symbol[i]) then self.edits.symbol[i] = string.sub (self.edits.symbol[i], 1, utf8.len(self.edits.symbol[i])-1) else self.edits.symbol[i] = self.edits.symbol[i].."|" end end end tableshmb = {"~","!","@","#","$","%","^","&","*","(",")","_","-","=","`","[","{","]","}",":",";","'",'"',"|","/",} function checkCharacter (text) local results = false for i, key in ipairs (tableshmb) do if text == key then results = true break end end return results end function addKeyCharacter (character) if self.edits.selected and self.edits.selection and character then if self.edits.selected == 1 then if utf8.len(self.edits.login) < 15 then if utf8.find(character, "%W") or utf8.find(character, "%w") or checkCharacter(character) then self.edits.login = self.edits.login..character end end elseif self.edits.selected == 2 then if utf8.len(self.edits.password) < 15 then if utf8.find(character, "%W") or utf8.find(character, "%w") or checkCharacter(character) then self.edits.password = self.edits.password..character end end elseif self.edits.selected == 3 then if utf8.len(self.edits.loginReg) < 15 then if utf8.find(character, "%W") or utf8.find(character, "%w") or checkCharacter(character) then self.edits.loginReg = self.edits.loginReg..character end end elseif self.edits.selected == 4 then if utf8.len(self.edits.passwordReg) < 15 then if utf8.find(character, "%W") or utf8.find(character, "%w") or checkCharacter(character) then self.edits.passwordReg = self.edits.passwordReg..character end end elseif self.edits.selected == 5 then if utf8.len(self.edits.passwordRegRef) < 15 then if utf8.find(character, "%W") or utf8.find(character, "%w") or checkCharacter(character) then self.edits.passwordRegRef = self.edits.passwordRegRef..character end end end end end function removeKeyCharacter (key, state) if not self.edits.selection then return end if key == "backspace" and self.edits.selected and state then if self.edits.selected == 1 then if utf8.len(self.edits.login) < 1 then return end self.edits.login = utf8.sub (self.edits.login, 1, utf8.len(self.edits.login)-1) elseif self.edits.selected == 2 then if utf8.len(self.edits.password) < 1 then return end self.edits.password = utf8.sub (self.edits.password, 1, utf8.len(self.edits.password)-1) elseif self.edits.selected == 3 then if utf8.len(self.edits.loginReg) < 1 then return end self.edits.loginReg = utf8.sub (self.edits.loginReg, 1, utf8.len(self.edits.loginReg)-1) elseif self.edits.selected == 4 then if utf8.len(self.edits.passwordReg) < 1 then return end self.edits.passwordReg = utf8.sub (self.edits.passwordReg, 1, utf8.len(self.edits.passwordReg)-1) elseif self.edits.selected == 5 then if utf8.len(self.edits.passwordRegRef) < 1 then return end self.edits.passwordRegRef = utf8.sub (self.edits.passwordRegRef, 1, utf8.len(self.edits.passwordRegRef)-1) end end end function Login.Interface:Render() dxDrawImage(0, 0, sw, sh, "assets/images/background.png"); dxDrawImage(self.PosX, self.PosY, self.Weight, self.Height, "assets/images/main.png", 0, 0, 0, tocolor(31, 36, 68, 255)); if self.edits.selection == 1 then -- Авторизация dxDrawText("Faça seu Login", self.PosX, self.PosY + 64 * px, self.Weight + self.PosX, self.Height, tocolor(255, 255, 255, self.i255), 0.5, self.medium3, "center", "top"); dxDrawImage(self.PosX + 203 * px, self.PosY + 93 * px, 38 * px, 5 * px, "assets/images/line.png", 0, 0, 0, tocolor(181, 72, 69, 255)); if cursorPosition(self.PosX + 291 * px, self.PosY + 460 * px, 109 * px, 25 * px) then if getKeyState("mouse1") and not self.click then self.edits.selection = 2 --iprint("Resource author: MightDragon") end dxDrawText("#6d738dEntao vamos nessa? #ffffffRegistre-se", self.PosX, self.PosY + 460 * px, self.Weight + self.PosX, 15 * px, tocolor(255, 255, 255, 255), 0.53, self.medium2, "center", "top", nil, nil, nil, true); dxDrawRectangle(self.PosX + 291 * px, self.PosY + 480 * px, 109 * px, 1 * px, tocolor(255, 255, 255, 255)); else dxDrawText("#6d738dNão tem uma conta? #ffffffRegistre-se", self.PosX, self.PosY + 460 * px, self.Weight + self.PosX, 15 * px, tocolor(255, 255, 255, 255), 0.53, self.medium2, "center", "top", nil, nil, nil, true); end dxCreateButton(( sw / 2) - ( 235 * px / 2 ), self.PosY + 317 * px, 235 * px, 86 * px, "assets/images/button.png", "assets/images/button2.png", 0); dxDrawText("Continuar", ( sw / 2) - ( 235 * px / 2 ), self.PosY + 317 * px, 235 * px + ( sw / 2) - ( 235 * px / 2 ), 86 * px + self.PosY + 317 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); -- Логин if cursorPosition(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px) then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); if self.edits.selected == 1 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.login == "" then dxDrawText("Digite o login", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 145 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(self.edits.login..self.edits.symbol[1], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 145 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center" ); end if getKeyState("mouse1") and not self.click then self.edits.selected = 1 end else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); if self.edits.selected == 1 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.login == "" then dxDrawText("Digite o login", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 145 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(self.edits.login..self.edits.symbol[1], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 145 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 145 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); end if getKeyState("mouse1") and not self.click and self.edits.selected == 1 then if string.len(self.edits.symbol[1]) > 0 then self.edits.symbol[1] = "" end self.edits.selected = nil end end -- Senha if cursorPosition(( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px, 58 * px) then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); if self.edits.selected == 2 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.password == "" then dxDrawText("Digite a senha", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 225 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(string.gsub (self.edits.password, "%C", "*")..self.edits.symbol[2], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 225 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); end if getKeyState("mouse1") and not self.click then self.edits.selected = 2 end else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); if self.edits.selected == 2 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ),self.PosY + 225 * px,359 * px,58 * px,"assets/images/input.png",0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.password == "" then dxDrawText("Digite a senha", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 225 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(string.gsub (self.edits.password, "%C", "*")..self.edits.symbol[2], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 225 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 225 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); end if getKeyState("mouse1") and not self.click and self.edits.selected == 2 then if string.len(self.edits.symbol[2]) > 0 then self.edits.symbol[2] = "" end self.edits.selected = nil end end if cursorPosition(( sw / 2) - ( 235 * px / 2 ), self.PosY + 317 * px, 235 * px, 86 * px) then if getKeyState("mouse1") and not self.click then local username = self.edits.login local password = self.edits.password triggerServerEvent("LoginAccountInServer", localPlayer, username, password, bollSave) --iprint("Resource author: MightDragon") end end end if self.edits.selection == 2 then -- Регистрация dxDrawText("Registrar", self.PosX, self.PosY + 64 * px, self.Weight + self.PosX, self.Height, tocolor(255, 255, 255, self.i255), 0.5, self.medium3, "center", "top"); dxDrawImage(self.PosX + 203 * px, self.PosY + 93 * px, 38 * px, 5 * px, "assets/images/line.png", 0, 0, 0, tocolor(181, 72, 69, 255)); if cursorPosition(self.PosX + 255 * px, self.PosY + 460 * px, 52 * px, 25 * px) then if getKeyState("mouse1") and not self.click then self.edits.selection = 1 --iprint("Resource author: MightDragon") end dxDrawText("Voltar", self.PosX, self.PosY + 460 * px, self.Weight + self.PosX, 15 * px, tocolor(255, 255, 255, 255), 0.53, self.medium2, "center", "top", nil, nil, nil, true); dxDrawRectangle(self.PosX + 255 * px, self.PosY + 480 * px, 52 * px, 1 * px, tocolor(255, 255, 255, 255)); else dxDrawText("Voltar", self.PosX, self.PosY + 460 * px, self.Weight + self.PosX, 15 * px, tocolor(255, 255, 255, 255), 0.53, self.medium2, "center", "top", nil, nil, nil, true); end -- Логин if cursorPosition(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px) then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); if self.edits.selected == 3 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.loginReg == "" then dxDrawText("Digite o login", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 125 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(self.edits.loginReg..self.edits.symbol[3], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 125 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center" ); end if getKeyState("mouse1") and not self.click then self.edits.selected = 3 end else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); if self.edits.selected == 3 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.loginReg == "" then dxDrawText("Digite o login", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 125 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(self.edits.loginReg..self.edits.symbol[3], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 125 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 125 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); end if getKeyState("mouse1") and not self.click and self.edits.selected == 3 then if string.len(self.edits.symbol[3]) > 0 then self.edits.symbol[3] = "" end self.edits.selected = nil end end -- Senha if cursorPosition(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px) then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); if self.edits.selected == 4 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.passwordReg == "" then dxDrawText("Digite a senha", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 205 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(string.gsub (self.edits.passwordReg, "%C", "*")..self.edits.symbol[4], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 205 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center" ); end if getKeyState("mouse1") and not self.click then self.edits.selected = 4 end else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); if self.edits.selected == 4 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.passwordReg == "" then dxDrawText("Digite a senha", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 205 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(string.gsub (self.edits.passwordReg, "%C", "*")..self.edits.symbol[4], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 205 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 205 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); end if getKeyState("mouse1") and not self.click and self.edits.selected == 4 then if string.len(self.edits.symbol[4]) > 0 then self.edits.symbol[4] = "" end self.edits.selected = nil end end -- Repita a senha if cursorPosition(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px) then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); if self.edits.selected == 5 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.passwordRegRef == "" then dxDrawText("Repita a senha", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 285 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(string.gsub (self.edits.passwordRegRef, "%C", "*")..self.edits.symbol[5], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 285 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center" ); end if getKeyState("mouse1") and not self.click then self.edits.selected = 5 end else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); if self.edits.selected == 5 then dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(50, 55, 89, 255)); else dxDrawImage(( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px, 58 * px, "assets/images/input.png", 0, 0, 0, tocolor(38, 43, 75, 255)); end if self.edits.passwordRegRef == "" then dxDrawText("Repita a senha", ( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 285 * px, tocolor(73, 78, 108, 255), 0.5, self.medium, "center", "center"); else dxDrawText(string.gsub (self.edits.passwordRegRef, "%C", "*")..self.edits.symbol[5], ( sw / 2) - ( 359 * px / 2 ), self.PosY + 285 * px, 359 * px + ( sw / 2) - ( 359 * px / 2 ), 58 * px + self.PosY + 285 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); end if getKeyState("mouse1") and not self.click and self.edits.selected == 5 then if string.len(self.edits.symbol[5]) > 0 then self.edits.symbol[5] = "" end self.edits.selected = nil end end dxCreateButton(( sw / 2) - ( 235 * px / 2 ), self.PosY + 357 * px, 235 * px, 86 * px, "assets/images/button.png", "assets/images/button2.png", 0); dxDrawText("Criar", ( sw / 2) - ( 235 * px / 2 ), self.PosY + 357 * px, 235 * px + ( sw / 2) - ( 235 * px / 2 ), 86 * px + self.PosY + 357 * px, tocolor(255, 255, 255, 255), 0.5, self.medium, "center", "center"); if cursorPosition(( sw / 2) - ( 235 * px / 2 ), self.PosY + 357 * px, 235 * px, 86 * px) then if getKeyState("mouse1") and not self.click then local username = self.edits.loginReg local password = self.edits.passwordReg local confirm = self.edits.passwordRegRef triggerServerEvent("RegisterAccountInServer", localPlayer, username, password, confirm) --iprint("Resource author: MightDragon") end end end if getKeyState ("mouse1") then self.click = true else self.click = false end end function ShowManager() Login.Interface:Render(); end function LoginInterfaceShow(state) self.isVisible = state; self.edits.selection = 1; showCursor(state); fadeCamera(state); if state == true then showChat(false) fadeCamera(false) elseif state == false then showChat(true) fadeCamera(true) end -- # Crutch if state then if not isEventHandlerAdded("onClientRender", root, ShowManager) then addEventHandler("onClientRender", root, ShowManager) end if not isEventHandlerAdded("onClientCharacter", root, addKeyCharacter) then addEventHandler("onClientCharacter", root, addKeyCharacter) end if not isEventHandlerAdded("onClientKey", root, removeKeyCharacter) then addEventHandler("onClientKey", root, removeKeyCharacter) end self.edits.timers[1] = setTimer (checkLine, 500, 0) else if isEventHandlerAdded("onClientRender", root, ShowManager) then removeEventHandler("onClientRender", root, ShowManager) end if isEventHandlerAdded("onClientCharacter", root, addKeyCharacter) then removeEventHandler("onClientCharacter", root, addKeyCharacter) end if isEventHandlerAdded("onClientKey", root, removeKeyCharacter) then removeEventHandler("onClientKey", root, removeKeyCharacter) end for k, t in pairs (self.edits.timers) do if isTimer (self.edits.timers[k]) then killTimer (self.edits.timers[k]) end end end end local settingsFile = "settings.json" function loadSettings() local data if fileExists(settingsFile) then local file = fileOpen(settingsFile, true) if (file) then data = fromJSON(fileRead(file, fileGetSize(file))) fileClose(file) end end if (type(data) ~= "table") then data = {} end local user = self.edits.login local pass = self.edits.password self.edits.login = data.user or "" self.edits.password = data.pass or "" end local needsSave, saveTimer = false function saveSettings() if isTimer(saveTimer) then needsSave = true else needsSave = true writeSettingsFile() saveTimer = setTimer(writeSettingsFile, 1000, 1) end end function writeSettingsFile() if (needsSave) then local data = {} data.user = self.edits.login data.pass = self.edits.password local file = fileCreate(settingsFile) if (file) then fileWrite(file, toJSON(data, true)) fileClose(file) end needsSave = false end end end; Login.Interface:onRender(); function CloseInterface() LoginInterfaceShow(false) end addEvent ("CloseInterfaceLogin", true) addEventHandler ("CloseInterfaceLogin", resourceRoot, CloseInterface) 1 Link to comment
rxqp Posted April 27, 2021 Share Posted April 27, 2021 vc pode usar a função util isEventHandlerAdded pra verificar se o painel esta renderizando (lembrando que e uma função util) ex addEventHandler("onClientKey", root, function (button, press) if isEventHandlerAdded("onClientRender", getRootElement(), LoginPanel) then if button == "F1" or button == "F2" or button == "F3" or button == "F4" or button == "F5" or button == "F6" or button == "F7" or button == "b" or button == "F9" or button == "F10" or button == "F11" or button == "F12" then cancelEvent() end end end) Lembrando que quando for fazer a verificação de um valor boolean, não e nescessario inserir a condição, apenas com o if (verificação) then ele reconhece que caso o valor seja true para continuar essa função obs: use no client (mude a função do isEventHandlerAdded) Link to comment
Boechat Posted April 27, 2021 Share Posted April 27, 2021 (edited) Use guiSetInputEnabled. guiSetInputEnabled(true) -- Desativa as binds e as teclas só funcionam pra textos (adicione quando abrir o painel de login) guiSetInputEnabled(false) -- Reativa as binds (Adicione quando o player fizer o login e fechar o painel) Edited April 27, 2021 by Boechat 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