Doongogar Posted March 8, 2023 Share Posted March 8, 2023 então eu tive que setar o postgui do da dx em true na hora que passa o mouse por cima para trocar o dx de cor porém agora que o dx esta em true quando a editbox e criada ela fica por tras do retangulo da dx, como eu sobre ponho a editbox sob o dx? Link to comment
Other Languages Moderators Lord Henry Posted March 8, 2023 Other Languages Moderators Share Posted March 8, 2023 Mostre a parte do código que você está tentando fazer. Link to comment
Doongogar Posted March 9, 2023 Author Share Posted March 9, 2023 (edited) local screenW, screenH = guiGetScreenSize() local states = false function DX_Global() dxDrawRectangle(screenW * 0.7331, screenH * 0.4033, screenW * 0.2081, screenH * 0.0356, tocolor(33, 33, 33, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.4389, screenW * 0.2081, screenH * 0.0044, tocolor(143, 9, 237, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Dinheiro dxDrawRectangle(screenW * 0.7331, screenH * 0.4700, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.4744, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Veiculo dxDrawRectangle(screenW * 0.7331, screenH * 0.5011, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Puxar dxDrawRectangle(screenW * 0.7331, screenH * 0.5322, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5367, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Mensagem dxDrawRectangle(screenW * 0.7331, screenH * 0.5633, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Destruir Veiculos dxDrawRectangle(screenW * 0.7331, screenH * 0.5944, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Players dxDrawText("Dinheiro:", screenW * 0.8219, screenH * 0.4500, screenW * 0.9550, screenH * 0.4744, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Veiculo:", screenW * 0.8244, screenH * 0.4811, screenW * 0.9575, screenH * 0.5056, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Puxar", screenW * 0.8275, screenH * 0.5122, screenW * 0.9606, screenH * 0.5367, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Destruir Todos os Veiculos", screenW * 0.7919, screenH * 0.5744, screenW * 0.9250, screenH * 0.5989, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Painel Global", 1261, 365, 1441, 399, tocolor(255, 255, 255, 255), 2.20, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Mensagem:", screenW * 0.8175, screenH * 0.5433, screenW * 0.9506, screenH * 0.5678, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawText("Players", screenW * 0.8237, screenH * 0.6056, screenW * 0.9569, screenH * 0.6300, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) dxDrawRectangle(screenW * 0.7331, screenH * 0.6300, screenW * 0.2081, screenH * 0.0356, tocolor(33, 33, 33, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.6256, screenW * 0.2081, screenH * 0.0044, tocolor(143, 9, 237, 255), false) end addEvent("Open:Global", true) addEventHandler("Open:Global", root, function() if states then removeEventHandler("onClientRender", root, DX_Global) else addEventHandler("onClientRender", root, DX_Global) end states = not states showCursor(states) end) function OpenPainel() if states == false then addEventHandler("onClientRender", root, DX_Global) states = true showCursor(true) else removeEventHandler("onClientRender", root, DX_Global) states = false showCursor(false) end end bindKey("num_5", "down", OpenPainel) bindKey("backspace", "down", function(key, keyState) if states and isCursorShowing() then removeEventHandler("onClientRender", root, DX_Global) showCursor(false) states = not states end end) addEventHandler("onClientRender", root, function() if isEventHandlerAdded("onClientRender", root, DX_Global) then if isCursorInPosition(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), true) -- Dinheiro elseif isCursorInPosition(screenW * 0.7331, screenH * 0.4744, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.4744, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), true) -- Veiculo elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), true) -- Puxar elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5367, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5367, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), true) -- Mensagem elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), true) -- Destruir Veiculos elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), true) -- Players end end end) addEventHandler("onClientClick", root, function(button, state) if states and isCursorShowing() then if button == "left" and state == "down" then if isCursorInPosition(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267) then -- Puxar triggerServerEvent("PuxarTodos", resourceRoot, localPlayer) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267) then -- Destruir Veiculos triggerServerEvent("DestruirVeiculos", resourceRoot) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267) then -- Players local contador = 0 for _, player in pairs(getElementsByType("player")) do if player then contador = contador + 1 end end outputChatBox("Existem: #00ff00"..contador.." #ffffffplayers online.", 255, 255, 255, true) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267) then -- Dinheiro local editBox = guiCreateEdit(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, "", false) end end end end ) function isCursorInPosition ( x, y, width, height ) if ( not isCursorShowing( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) ) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end Edited March 9, 2023 by SciptNovato Link to comment
Other Languages Moderators Lord Henry Posted March 9, 2023 Other Languages Moderators Share Posted March 9, 2023 Não vejo necessidade de definir true no postGUI dos DX. Basta dar dxDraw neles na ordem correta. Spoiler local screenW, screenH = guiGetScreenSize() local states = false function DX_Global() dxDrawRectangle(screenW * 0.7331, screenH * 0.4033, screenW * 0.2081, screenH * 0.0356, tocolor(33, 33, 33, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.4389, screenW * 0.2081, screenH * 0.0044, tocolor(143, 9, 237, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Dinheiro dxDrawRectangle(screenW * 0.7331, screenH * 0.4700, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.4744, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Veiculo dxDrawRectangle(screenW * 0.7331, screenH * 0.5011, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Puxar dxDrawRectangle(screenW * 0.7331, screenH * 0.5322, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5367, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Mensagem dxDrawRectangle(screenW * 0.7331, screenH * 0.5633, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Destruir Veiculos dxDrawRectangle(screenW * 0.7331, screenH * 0.5944, screenW * 0.2081, screenH * 0.0044, tocolor(12, 12, 12, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267, tocolor(21, 21, 21, 255), false) -- Players dxDrawRectangle(screenW * 0.7331, screenH * 0.6300, screenW * 0.2081, screenH * 0.0356, tocolor(33, 33, 33, 255), false) dxDrawRectangle(screenW * 0.7331, screenH * 0.6256, screenW * 0.2081, screenH * 0.0044, tocolor(143, 9, 237, 255), false) if isCursorInPosition(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), false) -- Dinheiro elseif isCursorInPosition(screenW * 0.7331, screenH * 0.4744, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.4744, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), false) -- Veiculo elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), false) -- Puxar elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5367, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5367, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), false) -- Mensagem elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), false) -- Destruir Veiculos elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267) then dxDrawRectangle(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267, tocolor(80, 0, 135, 255), false) -- Players end dxDrawText("Dinheiro:", screenW * 0.8219, screenH * 0.4500, screenW * 0.9550, screenH * 0.4744, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top") dxDrawText("Veiculo:", screenW * 0.8244, screenH * 0.4811, screenW * 0.9575, screenH * 0.5056, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top") dxDrawText("Puxar", screenW * 0.8275, screenH * 0.5122, screenW * 0.9606, screenH * 0.5367, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top") dxDrawText("Destruir Todos os Veiculos", screenW * 0.7919, screenH * 0.5744, screenW * 0.9250, screenH * 0.5989, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top") dxDrawText("Painel Global", 1261, 365, 1441, 399, tocolor(255, 255, 255, 255), 2.20, "default-bold", "left", "top") dxDrawText("Mensagem:", screenW * 0.8175, screenH * 0.5433, screenW * 0.9506, screenH * 0.5678, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top") dxDrawText("Players", screenW * 0.8237, screenH * 0.6056, screenW * 0.9569, screenH * 0.6300, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top") end addEvent("Open:Global", true) addEventHandler("Open:Global", root, function() if states then removeEventHandler("onClientRender", root, DX_Global) else addEventHandler("onClientRender", root, DX_Global) end states = not states showCursor(states) end) function OpenPainel() if states == false then addEventHandler("onClientRender", root, DX_Global) states = true showCursor(true) else removeEventHandler("onClientRender", root, DX_Global) states = false showCursor(false) if isElement(editBox) then destroyElement(editBox) editBox = nil end end end bindKey("num_5", "down", OpenPainel) -- bindKey("backspace", "down", function(key, keyState) -- Desnecessário, pois a tecla num_5 já faz isso. Além disso, vai ativar ao tentar apagar o texto do editBox. -- if states and isCursorShowing() then -- removeEventHandler("onClientRender", root, DX_Global) -- showCursor(false) -- states = not states -- end -- end) addEventHandler("onClientClick", root, function(button, state) if states and isCursorShowing() then if button == "left" and state == "down" then if isCursorInPosition(screenW * 0.7331, screenH * 0.5056, screenW * 0.2081, screenH * 0.0267) then -- Puxar triggerServerEvent("PuxarTodos", resourceRoot, localPlayer) -- Não precisa passar localPlayer por parâmetro, é só usar a variável client lá no server.lua elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5678, screenW * 0.2081, screenH * 0.0267) then -- Destruir Veiculos triggerServerEvent("DestruirVeiculos", resourceRoot) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.5989, screenW * 0.2081, screenH * 0.0267) then -- Players local contador = 0 for _, player in pairs(getElementsByType("player")) do if player then contador = contador + 1 end end outputChatBox("Existem: #00ff00"..contador.." #ffffffplayers online.", 255, 255, 255, true) elseif isCursorInPosition(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267) then -- Dinheiro editBox = guiCreateEdit(screenW * 0.7331, screenH * 0.4433, screenW * 0.2081, screenH * 0.0267, "", false) guiFocus(editBox) -- Seria bom você definir o limite de caracteres do editBox. end end end end) function isCursorInPosition (x, y, width, height) if (not isCursorShowing()) then return false end local sx, sy = guiGetScreenSize() local cx, cy = getCursorPosition() local cx, cy = (cx * sx), (cy * sy) return ((cx >= x and cx <= x + width) and (cy >= y and cy <= y + height)) end 1 Link to comment
Doongogar Posted March 10, 2023 Author Share Posted March 10, 2023 brigadão, eu tinha setado o postgui em true pq na hora de selecionar o painel ficava por cima do retangulo de roxo de quando selecionava ent não aparecia, não sabia que tinha como juntar assim o painel com o de por o mouse em cima, outra, esse guifocus faz oque exatamente, eu pesquisei, e li na wiki que foca um elemento, não entendi muito bem Link to comment
Other Languages Moderators Lord Henry Posted March 10, 2023 Other Languages Moderators Share Posted March 10, 2023 (edited) guiFocus move o elemento cegui pra frente como se você tivesse clicado nele. No caso de editbox e memos, ele também coloca o cursor de digitação nele. Assim você não precisa clicar no campo de input antes de digitar, pois o cursor de texto já estará lá. Um exemplo básico é este campo de texto aqui no fórum. Por padrão ele vem "fechado" quando você abre esta página. Então você precisa clicar nele para abrir e depois pode começar a digitar sua mensagem. O guiFocus faz isso no MTA, ele meio que "clica" no editBox para você poder digitar direto sem precisar clicar nele antes. Ele também pode ser usado em janelas cegui que estejam sobrepostas. Use guiFocus na janela que deseja mover para frente como se clicasse nela. O guiFocus também é útil para mover para frente os elementos que você não consegue clicar pois tem algo na frente atrapalhando. A função oposta ao guiFocus é o guiBlur. Normalmente só usamos isso em editFields e memos, para quando você quer parar de digitar neles, como se fosse clicar fora deles pro cursor de texto sair deles. Você também pode usar guiBringToFront para mover um elemento gui para frente. Mas no caso de editBox e memos, o cursor de texto não aparece neles com essa função, sendo necessário clicar neles para poder digitar. Seu oposto é o guiMoveToBack, a diferença dele pro guiBlur, é que no caso de editBox e memos, o cursor de texto continua neles mesmo eles estando atrás de outros elementos gui. Resumindo: guiFocus e guiBlur "clicam" e "desclicam" os elementos gui, além de movê-los para frente e para trás. Enquanto que guiBringToFront e guiMoveToBack apenas movem para frente ou para trás sem "clicar" nem "desclicar" neles. Edited March 10, 2023 by Lord Henry 1 Link to comment
Recommended Posts