Doongogar Posted February 24, 2023 Share Posted February 24, 2023 (edited) aqui quando eu clicko no botão de sair do trabalho não acontece nada, nem da erro no debug addEvent("Open:Ilegal", true) addEventHandler("Open:Ilegal", root, function() if states then removeEventHandler("onClientRender", root, DX_Entregas) else addEventHandler("onClientRender", root, DX_Entregas) end states = not states showCursor(states) end) bindKey("backspace", "down", function() if states == true and isCursorShowing() then removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) end end) addEventHandler( "onClientClick", root, function( button, state ) if states == true then if ( button == "left" and state == "down" ) then if isMouseInPosition( screenW * 0.4019, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533 ) then if getElementData(localPlayer, "EntregadorD") == false then setElementData(localPlayer, "EntregadorD", true) exports._infobox:addNotification("Você Agora Trabalha na Entrega Ilegal!", "info") removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) elseif isMouseInPosition( screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533 ) then if getElementData(localPlayer, "EntregadorD") == true then exports._infobox:addNotification("Você Saiu do Emprego de Entregas Ilegais!", "info") setElementData(localPlayer, "EntregadorD", false) removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) else removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) end end end end end end ) e tambem quando clicko na posição do botão mesmo sem o painel estar aberto as funções são executadas como se estivesse aberto Edited February 24, 2023 by SciptNovato Link to comment
Other Languages Moderators Lord Henry Posted February 25, 2023 Other Languages Moderators Share Posted February 25, 2023 (edited) Isso acontece pois além de errar na indentação, você não percebeu que faltou colocar states = false depois do showCursor(false) Além disso, seu isMouseInPosition não parece estar seguindo a mesma posição dos botões do painel (a não ser que você mudou o painel e não mostrou ele) Também seria interessante você incluir as funções úteis que você está usando, fica complicado de testar seu script se você não inclui as funções úteis. Spoiler local screenW, screenH = guiGetScreenSize() local states = false function DX_Entregas() dxDrawRectangle(screenW * 0.3794, screenH * 0.2467, screenW * 0.2288, screenH * 0.4833, tocolor(31, 31, 31, 255), false) dxDrawRectangle(screenW * 0.3794, screenH * 0.2356, screenW * 0.2288, screenH * 0.0111, tocolor(116, 0, 165, 255), false) dxDrawRoundedRectangle(screenW * 0.3956, screenH * 0.2711, screenW * 0.1969, screenH * 0.3333, 15, tocolor(82, 82, 82, 224), false) dxDrawRoundedRectangle(screenW * 0.4019, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533, 15, tocolor(82, 82, 82, 224), false) dxDrawRoundedRectangle(screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533, 15, tocolor(82, 82, 82, 224), false) dxDrawText("SIM", screenW * 0.4200, screenH * 0.6489, screenW * 0.4788, screenH * 0.6778, tocolor(25, 232, 4, 255), 3.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("NÃO", screenW * 0.5240, screenH * 0.6489, screenW * 0.5837, screenH * 0.6778, tocolor(237, 0, 0, 255), 3.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Você quer trabalhar entregando drogas?", screenW * 0.4200, screenH * 0.2822, screenW * 0.6019, screenH * 0.3122, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Receber uma van no local ao lado", screenW * 0.4044, screenH * 0.3267, screenW * 0.5863, screenH * 0.3567, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Entregar a carga em um local secreto", screenW * 0.4044, screenH * 0.3567, screenW * 0.5863, screenH * 0.3867, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Receber de 10000 a 13000 de Dinheiro Sujo", screenW * 0.4044, screenH * 0.3867, screenW * 0.5863, screenH * 0.4211, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) end addEvent("Open:Ilegal", true) addEventHandler("Open:Ilegal", root, function() if states then removeEventHandler("onClientRender", root, DX_Entregas) else addEventHandler("onClientRender", root, DX_Entregas) end states = not states showCursor(states) end) bindKey("backspace", "down", function(key, keyState) if states and isCursorShowing() then removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) states = not states end end) addEventHandler("onClientClick", root, function(button, state) if states then if (button == "left" and state == "down") then if isMouseInPosition(screenW * 0.4019, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533) then -- SIM if not getElementData(localPlayer, "EntregadorD") then setElementData(localPlayer, "EntregadorD", true) -- exports._infobox:addNotification("Você Agora Trabalha na Entrega Ilegal!", "info") print("Você Agora Trabalha na Entrega Ilegal!") removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) states = false end elseif isMouseInPosition(screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533) then -- NÃO if getElementData(localPlayer, "EntregadorD") then -- exports._infobox:addNotification("Você Saiu do Emprego de Entregas Ilegais!", "info") print("Você Saiu do Emprego de Entregas Ilegais!") setElementData(localPlayer, "EntregadorD", false) end removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) states = false end end end end) function isMouseInPosition (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 dxDrawRoundedRectangle(x, y, rx, ry, radius, color, postGUI) rx = rx - radius * 2 ry = ry - radius * 2 x = x + radius y = y + radius if (rx >= 0) and (ry >= 0) then dxDrawRectangle(x, y, rx, ry, color, postGUI) dxDrawRectangle(x, y - radius, rx, radius, color, postGUI) dxDrawRectangle(x, y + ry, rx, radius, color, postGUI) dxDrawRectangle(x - radius, y, radius, ry, color, postGUI) dxDrawRectangle(x + rx, y, radius, ry, color, postGUI) dxDrawCircle(x, y, radius, 180, 270, color, color, 7, 1, postGUI) dxDrawCircle(x + rx, y, radius, 270, 360, color, color, 7, 1, postGUI) dxDrawCircle(x + rx, y + ry, radius, 0, 90, color, color, 7, 1, postGUI) dxDrawCircle(x, y + ry, radius, 90, 180, color, color, 7, 1, postGUI) end end Fiz várias correções, dê uma estudada nas diferenças. Edited February 25, 2023 by Lord Henry Link to comment
Doongogar Posted February 25, 2023 Author Share Posted February 25, 2023 a linha do retangulo do não é essa dxDrawRoundedRectangle(screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533, 15, tocolor(82, 82, 82, 224), false) e o do mouse é essa elseif isMouseInPosition( screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533 ) then quando clicko no sim funciona porém no não não acontece nada o codigo todo ta assim: -------------------------------------------------- Funções Utils -------------------------------------------------- function dxDrawRoundedRectangle(x, y, width, height, radius, color, postGUI, subPixelPositioning) dxDrawRectangle(x+radius, y+radius, width-(radius*2), height-(radius*2), color, postGUI, subPixelPositioning) dxDrawCircle(x+radius, y+radius, radius, 180, 270, color, color, 16, 1, postGUI) dxDrawCircle(x+radius, (y+height)-radius, radius, 90, 180, color, color, 16, 1, postGUI) dxDrawCircle((x+width)-radius, (y+height)-radius, radius, 0, 90, color, color, 16, 1, postGUI) dxDrawCircle((x+width)-radius, y+radius, radius, 270, 360, color, color, 16, 1, postGUI) dxDrawRectangle(x, y+radius, radius, height-(radius*2), color, postGUI, subPixelPositioning) dxDrawRectangle(x+radius, y+height-radius, width-(radius*2), radius, color, postGUI, subPixelPositioning) dxDrawRectangle(x+width-radius, y+radius, radius, height-(radius*2), color, postGUI, subPixelPositioning) dxDrawRectangle(x+radius, y, width-(radius*2), radius, color, postGUI, subPixelPositioning) end function isMouseInPosition ( 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 isCursorOverText(posX, posY, sizeX, sizeY) if ( not isCursorShowing( ) ) then return false end local cX, cY = getCursorPosition() local screenWidth, screenHeight = guiGetScreenSize() local cX, cY = (cX*screenWidth), (cY*screenHeight) return ( (cX >= posX and cX <= posX+(sizeX - posX)) and (cY >= posY and cY <= posY+(sizeY - posY)) ) end -------------------------------------------------- Funções / Painel -------------------------------------------------- local screenW, screenH = guiGetScreenSize() function DX_Entregas() dxDrawRectangle(screenW * 0.3794, screenH * 0.2467, screenW * 0.2288, screenH * 0.4833, tocolor(31, 31, 31, 255), false) dxDrawRectangle(screenW * 0.3794, screenH * 0.2356, screenW * 0.2288, screenH * 0.0111, tocolor(116, 0, 165, 255), false) dxDrawRoundedRectangle(screenW * 0.3956, screenH * 0.2711, screenW * 0.1969, screenH * 0.3333, 15, tocolor(82, 82, 82, 224), false) dxDrawRoundedRectangle(screenW * 0.4019, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533, 15, tocolor(82, 82, 82, 224), false) dxDrawRoundedRectangle(screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533, 15, tocolor(82, 82, 82, 224), false) dxDrawText("SIM", screenW * 0.4200, screenH * 0.6489, screenW * 0.4788, screenH * 0.6778, tocolor(25, 232, 4, 255), 3.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("NÃO", screenW * 0.5240, screenH * 0.6489, screenW * 0.5837, screenH * 0.6778, tocolor(237, 0, 0, 255), 3.00, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("Você Quer Trabalhar Entregando Drogas?", screenW * 0.4200, screenH * 0.2822, screenW * 0.6019, screenH * 0.3122, tocolor(255, 255, 255, 255), 1.1, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Receber uma Van no Local ao Lado", screenW * 0.4044, screenH * 0.3267, screenW * 0.5863, screenH * 0.3567, tocolor(255, 255, 255, 255), 1.1, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Entregar a Carga em um Local Secreto", screenW * 0.4044, screenH * 0.3567, screenW * 0.5863, screenH * 0.3867, tocolor(255, 255, 255, 255), 1.1, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Receber de R$8000 a R$9000 de Dinheiro Sujo", screenW * 0.4044, screenH * 0.4167, screenW * 0.5863, screenH * 0.4211, tocolor(255, 255, 255, 255), 1.1, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Caso Saia da Van Perderá a Carga", screenW * 0.4044, screenH * 0.4467, screenW * 0.5863, screenH * 0.4211, tocolor(255, 255, 255, 255), 1.1, "default-bold", "left", "top", false, false, false, false, false) dxDrawText("--Caso a Van Quebre Perderá a Carga", screenW * 0.4044, screenH * 0.4767, screenW * 0.5863, screenH * 0.4211, tocolor(255, 255, 255, 255), 1.1, "default-bold", "left", "top", false, false, false, false, false) end addEvent("Open:Ilegal", true) addEventHandler("Open:Ilegal", root, function() if states then removeEventHandler("onClientRender", root, DX_Entregas) else addEventHandler("onClientRender", root, DX_Entregas) end states = not states showCursor(states) end) bindKey("backspace", "down", function(key, keyState) if states and isCursorShowing() then removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) states = not states end end) addEventHandler( "onClientClick", root, function( button, state ) if states == true then if ( button == "left" and state == "down" ) then if isMouseInPosition( screenW * 0.4019, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533 ) then if getElementData(localPlayer, "EntregadorD") == false then setElementData(localPlayer, "EntregadorD", true) exports._infobox:addNotification("Você Agora Trabalha na Entrega Ilegal!", "info") removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) elseif isMouseInPosition( screenW * 0.5094, screenH * 0.6444, screenW * 0.0769, screenH * 0.0533 ) then if getElementData(localPlayer, "EntregadorD") == true then setElementData(localPlayer, "EntregadorD", false) exports._infobox:addNotification("Você Saiu do Emprego de Entregas Ilegais!", "info") removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) else removeEventHandler("onClientRender", root, DX_Entregas) showCursor(false) end end end end end end ) perdão não colocar as funções úteis achei que quanto menos linhas, menos desgastante é ler Link to comment
Other Languages Moderators Lord Henry Posted February 25, 2023 Other Languages Moderators Share Posted February 25, 2023 Copie meu código e apenas atualize o painel e as linhas do isMouseInPosition pra ficarem iguais aos botões novos. Sobre quanto menos linhas é melhor sim para a gente ler, mas para casos onde a gente precisa testar o script, dai precisa das demais partes que tem relação com o problema. Nesse caso por exemplo, você não precisa incluir a parte do funcionamento do trabalho, pois o problema está apenas relacionado ao painel. 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