Jump to content

Criando menu em DX (botao bugado) ajuda pfv


Recommended Posts

Boa noite, estou tentando fazer um menu de dialogo em DX, porem quando clico na primeira opção pra ir pra proxima fala, pula direto pra ultima...
Gostaria de saber oq estou fazendo de errado para corrigir... OBG

Não esta completo porque estive tentando resolver esse problema

 

OBG

COD 

local szx,szy = guiGetScreenSize()

local dxfont0_fonte = dxCreateFont("font/fonte.ttf", 9)
local dxfont1_fonte = dxCreateFont("font/fonte.ttf", 18)
local dxfont2_fonte = dxCreateFont("font/fonte.ttf", 12)

local tx, ty, tz = 1383.2821044922, -1299.0447998047, 13.548862457275 
local sz = tz-1.9
local marker = createMarker (tx, ty, sz, "cylinder", 5, 241, 155, 0, 0)


local screenW, screenH = guiGetScreenSize()

--local inutil = createMarker (2029.20374, -1408.89844, 14.59219, "cylinder", 3, 241, 155, 0, alpha) 

local stats = 0

cores = {}

function dxMenu1 () -- Menu inicial

		-- cores --
		 cores[1] = tocolor(0,255,127,181) -- Botao 1
		 cores[2] = tocolor(0,128,0,222)   -- Cor verde escuro		
		 cores[3] = tocolor(0,255,127,181) -- Botao 2
		 cores[4] = tocolor(178,34,34, 181) -- Botao 3 (exit)
		 cores[5] = tocolor(255, 0, 0, 200) -- Botao 3 passado

		 
	-- Mudar cores dos botoes
				if cursorPosition(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378) then cores[1] = cores[2] end
				if cursorPosition(screenW * 0.5532, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then cores[3] = cores[2] end
				if cursorPosition(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then cores[4] = cores[5] end


		-- MENU DX--
	--	dxDrawImage(screenW * 0.3441, screenH * 0.3971, screenW * 0.1051, screenH * 0.2474, "graphic/armor.png", 0, 0, 0, tocolor(255, 255, 255, 228), false)
		dxDrawRectangle(screenW * 0.3132, screenH * 0.6816, screenW * 0.3662, screenH * 0.2474, tocolor(0, 0, 0, 212), false)

		dxDrawRectangle(screenW * 0.3132, screenH * 0.6797, screenW * 0.3662, screenH * 0.0339, tocolor(0, 0, 0, 181), false)
        dxDrawText("TITULO", screenW * 0.3338, screenH * 0.6849, screenW * 0.5265, screenH * 0.7070, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false) 

		dxDrawText("Ola!", screenW * 0.3306, screenH * 0.7620, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false)

		dxDrawRectangle(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378, cores[4], false)
		dxDrawText("SAIR", screenW * 0.3432, screenH * 0.8816, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)

        dxDrawRectangle(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378, cores[1], false)
     	dxDrawText("ARMAS", screenW * 0.8132, screenH * 0.8320, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)

	    dxDrawRectangle(screenW * 0.5532, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378, cores[3], false)
     	dxDrawText("RECICLAGEM", screenW * 0.8132, screenH * 0.8820, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
 
    end

	


function dxMenu2 () -- FALA 2

		-- cores --
		 cores[1] = tocolor(0,255,127,181) -- Botao 1
		 cores[2] = tocolor(0,128,0,222)   -- Cor verde escuro		
		 cores[3] = tocolor(0,255,127,181) -- Botao 2
		 cores[4] = tocolor(178,34,34, 181) -- Botao 3 (exit)
		 cores[5] = tocolor(255, 0, 0, 200) -- Botao 3 passado
		 
		 
	-- Mudar cores dos botoes
				if cursorPosition(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378) then cores[1] = cores[2] end
				if cursorPosition(screenW * 0.5532, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then cores[3] = cores[2] end
				if cursorPosition(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then cores[4] = cores[5] end
		
		
		-- MENU DX--
	--	dxDrawImage(screenW * 0.3441, screenH * 0.3971, screenW * 0.1051, screenH * 0.2474, "graphic/armor.png", 0, 0, 0, tocolor(255, 255, 255, 228), false)
		dxDrawRectangle(screenW * 0.3132, screenH * 0.6816, screenW * 0.3662, screenH * 0.2474, tocolor(0, 0, 0, 212), false)

		dxDrawRectangle(screenW * 0.3132, screenH * 0.6797, screenW * 0.3662, screenH * 0.0339, tocolor(0, 0, 0, 181), false)
        dxDrawText("TITULO", screenW * 0.3338, screenH * 0.6849, screenW * 0.5265, screenH * 0.7070, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false) 

		dxDrawText("", screenW * 0.3306, screenH * 0.8020, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false)
     	
        dxDrawRectangle(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378, cores[1], false)
     	dxDrawText("CIVIL", screenW * 0.8132, screenH * 0.8320, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
  
	    dxDrawRectangle(screenW * 0.5532, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378, cores[3], false)
     	dxDrawText("MILITAR", screenW * 0.8132, screenH * 0.8820, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
  
  		dxDrawRectangle(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378, cores[4], false)
		dxDrawText("VOLTAR", screenW * 0.3432, screenH * 0.8816, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
	
    end



function dxMenu3 () -- FALA 3

		-- cores --
		 cores[1] = tocolor(0,255,127,181) -- Botao 1
		 cores[2] = tocolor(0,128,0,222)   -- Cor verde escuro		
		 cores[3] = tocolor(0,255,127,181) -- Botao 2
		 cores[4] = tocolor(178,34,34, 181) -- Botao 3 (exit)
		 cores[5] = tocolor(255, 0, 0, 200) -- Botao 3 passado
		 
		 
	-- Mudar cores dos botoes
				if cursorPosition(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378) then cores[1] = cores[2] end
				if cursorPosition(screenW * 0.5532, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then cores[3] = cores[2] end
				if cursorPosition(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then cores[4] = cores[5] end
		
		
		-- MENU DX--
	--	dxDrawImage(screenW * 0.3441, screenH * 0.3971, screenW * 0.1051, screenH * 0.2474, "graphic/armor.png", 0, 0, 0, tocolor(255, 255, 255, 228), false)
		dxDrawRectangle(screenW * 0.3132, screenH * 0.6816, screenW * 0.3662, screenH * 0.2474, tocolor(0, 0, 0, 212), false)

		dxDrawRectangle(screenW * 0.3132, screenH * 0.6797, screenW * 0.3662, screenH * 0.0339, tocolor(0, 0, 0, 181), false)
        dxDrawText("titulo", screenW * 0.3338, screenH * 0.6849, screenW * 0.5265, screenH * 0.7070, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false) 

		dxDrawText("", screenW * 0.3306, screenH * 0.8020, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "left", "top", false, false, false, false, false)
     	
        dxDrawRectangle(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378, cores[1], false)
     	dxDrawText("CIVIL", screenW * 0.8132, screenH * 0.8320, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
  
	    dxDrawRectangle(screenW * 0.5532, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378, cores[3], false)
     	dxDrawText("MILITAR", screenW * 0.8132, screenH * 0.8820, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
  
  		dxDrawRectangle(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378, cores[4], false)
		dxDrawText("VOLTAR", screenW * 0.3432, screenH * 0.8816, screenW * 0.4132, screenH * 0.3841, tocolor(255, 255, 255, 222), 1.00, dxfont0_fonte, "center", "top", false, false, false, false, false)
	
    end

-- Abrir Menu --	
function abrirpainelMenu1 ()
    if stats == 0 then
       addEventHandler ("onClientRender", root, dxMenu1)
       showCursor (true)
       stats = stats+1
    end
end
addEvent ("opendxMenu1", true)
addEventHandler ("opendxMenu1", root, abrirpainelMenu1)


--[[
	-- MENU 1 --
				]]--	
-- Botao 1 --
function BMenu1_1 (_,state)
    if stats == 1 then
	 if (state == "down") then
	  if (isCursorOnElement(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378)) then
		stats = stats+1
		removeEventHandler("onClientRender", root, dxMenu1)
		addEventHandler ("onClientRender", root, dxMenu2)

	end
  end
 end
end
addEventHandler ("onClientClick", root, BMenu1_1)

-- Botao 3 --	
function BMenu1_3 (_,state)
    if stats == 1 then
     if state == "down" then
      if isCursorOnElement(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378) then 
		removeEventHandler("onClientRender", root, dxMenu1)
		showCursor (false)
		stats = stats-1
      end
    end
  end
end
addEventHandler ("onClientClick", root, BMenu1_3)

 


--[[
	-- MENU 2 --
				]]--		
-- Botao 1 --
function BMenu2_1 (_,state)
	  if stats == 2 then
	 if (state == "down") then
	  if (isCursorOnElement(screenW * 0.5532, screenH * 0.8216, screenW * 0.1162, screenH * 0.0378)) then
		stats = stats+1
		removeEventHandler("onClientRender", root, dxMenu2)
		addEventHandler ("onClientRender", root, dxMenu3)
	end
  end
 end
end
addEventHandler ("onClientClick", root, BMenu2_1)

-- Botao 3 --				
function BMenu2_3 (_,state)
	  if stats == 2 then
	 if (state == "down") then
	  if (isCursorOnElement(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378)) then
		removeEventHandler("onClientRender", root, dxMenu2)
		stats = stats-1
		addEventHandler ("onClientRender", root, dxMenu1)
	end
  end
 end
end
addEventHandler ("onClientClick", root, BMenu2_3)


--[[
	-- MENU 3 --
]]--
-- Botao 3 --				
function BMenu3_3 (_,state)

	if stats == 3 then
	 if (state == "down") then
	  if (isCursorOnElement(screenW * 0.3232, screenH * 0.8716, screenW * 0.1162, screenH * 0.0378)) then
		removeEventHandler("onClientRender", root, dxMenu3)
		stats = stats-1
		addEventHandler ("onClientRender", root, dxMenu2)

	end
  end
 end
end
addEventHandler ("onClientClick", root, BMenu3_3)






local x,y = guiGetScreenSize()
 function isCursorOnElement(x,y,w,h)
	local mx,my = getCursorPosition ()
	local fullx,fully = guiGetScreenSize()
	cursorx,cursory = mx*fullx,my*fully
	if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
		return true
	else
		return false
	end
end

function cursorPosition(x, y, w, h)
        if (not isCursorShowing()) then
                return false
        end
        local mx, my = getCursorPosition()
        local fullx, fully = guiGetScreenSize()
        cursorx, cursory = mx*fullx, my*fully
        if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
                return true
        else
                return false
        end
end

addEventHandler ( "onClientRender", root,
function ( )
         vx, vy, vz = getElementPosition(marker)
         scX, scY = getScreenFromWorldPosition(vx, vy, vz+3.5)
         cx,cy,cz,clx,cly,clz,crz,cfov = getCameraMatrix()
         dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz+3.5)
        if scX then
                 largura, altura = 212, 240
                 Tx = scX-(1000/dist)*szx/800/largura*cfov
                 Ty = scY-(100/dist)*szy/600/altura*cfov
                 Tw = (1000/dist)*szx/400/largura*cfov
                 Th = (1000/dist)*szy/400/altura*cfov
                 if dist < 80.0 then
                        if (isLineOfSightClear(cx, cy, cz, vx, vy, vz+1.5, true, false, false)) then
                                if not isElementWithinMarker(localPlayer, marker) then
                                    dxDrawImage ( Tx, Ty, Tw, Th, "graphic/sale.png",0,0,0,tocolor(255,255,255,math.abs(math.sin(getTickCount()/700))*255))
                                end
                                
                        end
                end
        end
end)

 

Edited by manojl
Link to comment
  • manojl changed the title to Criando menu em DX (botao bugado) ajuda pfv

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...