Jump to content

Comandos em Painel DX por marker


Recommended Posts

Faz um tempo que não criava scripts e antes eu só fazia o básico.

Eu estou com um painel DX que abre por acl ao passar no marker mas eu não estou conseguindo adicionar funções aos botões (skins e arma), pois faz tempo que eu não criava nada e não achei nenhum post para me ajudar nisso, por ser um painel por marker por acl e não somente bind é um pouco diferente acredito eu.

Link to comment
function drawDX()
        dxDrawImage(650, 82, 520, 522, "painelpmerj.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(852, 255, 117, 24, tocolor(0, 0, 0, 110), false)
        dxDrawRectangle(852, 289, 117, 24, tocolor(0, 0, 0, 110), false)
        dxDrawRectangle(852, 323, 117, 24, tocolor(0, 0, 0, 110), false)
        dxDrawRectangle(852, 357, 117, 24, tocolor(0, 0, 0, 110), false)
        dxDrawRectangle(868, 401, 91, 22, tocolor(0, 0, 0, 110), false)
        dxDrawText("Farda 04", 853, 357, 969, 381, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Farda 03", 852, 323, 968, 347, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Farda 02", 852, 289, 968, 313, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Farda 01", 852, 255, 968, 279, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
        dxDrawText("Fechar", 867, 399, 959, 423, tocolor(255, 255, 255, 200), 0.90, "default-bold", "center", "center", false, false, false, false, false) 

end
local isDxShowing = false
function gerenciaPainel ()
	if not isDxShowing then
		addEventHandler ("onClientRender", getRootElement(), drawDX)
		showCursor (true)
		isDxShowing = true
	else
		removeEventHandler ("onClientRender", getRootElement(), drawDX)
		showCursor (false)
		isDxShowing = false
	end
end

addEvent ("ativaPainel", true)
addEventHandler ("ativaPainel", getRootElement(), gerenciaPainel)
addEventHandler ("onClientClick", getRootElement(), function (button, state, absoluteX, absoluteY)
	if (button == "left") and (state == "up") and isDxShowing then
		if absoluteX >= 860 and absoluteX <= 960 and absoluteY >= 400 and absoluteY <= 430 then 
			gerenciaPainel () 
		end
	end
end)
theMarker = createMarker ( 1570.39 + 2, -1646.26206545297 + 2, 16.1, "cylinder", 1.5, 30, 144, 255, 30 )
addEventHandler ("onMarkerHit", theMarker, function (hitElement)
    if hitElement and getElementType (hitElement) == "player" then
        local account = getAccountName (getPlayerAccount (hitElement))
        if isObjectInACLGroup ("user."..account, aclGetGroup ("PM")) then
            triggerClientEvent (hitElement, "ativaPainel", hitElement)
        end
    end
end)

 

 

Link to comment
  • Other Languages Moderators
local isDxShowing = false

function drawDX()
	dxDrawImage(650, 82, 520, 522, "painelpmerj.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
	dxDrawRectangle(852, 255, 117, 24, tocolor(0, 0, 0, isCursorOnElement (852, 255, 117, 24) and 200 or 110), false) -- Retângulos que ficam com alpha em 200 quando o mouse está em cima.
	dxDrawRectangle(852, 289, 117, 24, tocolor(0, 0, 0, isCursorOnElement (852, 289, 117, 24) and 200 or 110), false)
	dxDrawRectangle(852, 323, 117, 24, tocolor(0, 0, 0, isCursorOnElement (852, 323, 117, 24) and 200 or 110), false)
	dxDrawRectangle(852, 357, 117, 24, tocolor(0, 0, 0, isCursorOnElement (852, 357, 117, 24) and 200 or 110), false)
	dxDrawRectangle(860, 401, 101, 22, tocolor(0, 0, 0, isCursorOnElement (860, 401, 101, 22) and 200 or 110), false)
	dxDrawText("Farda 04", 852, 357, 969, 381, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("Farda 03", 852, 323, 969, 347, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("Farda 02", 852, 289, 969, 313, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("Farda 01", 852, 255, 969, 279, tocolor(255, 255, 255, 200), 1.00, "default-bold", "center", "center", false, false, false, false, false)
	dxDrawText("Fechar", 860, 399, 961, 423, tocolor(255, 255, 255, 200), 0.90, "default-bold", "center", "center", false, false, false, false, false)
end

function gerenciaPainel ()
	if isDxShowing then
		removeEventHandler ("onClientRender", getRootElement(), drawDX)
		showCursor (false)
		isDxShowing = false
	else
		addEventHandler ("onClientRender", getRootElement(), drawDX)
		showCursor (true)
		isDxShowing = true
	end
end
addEvent ("ativaPainel", true)
addEventHandler ("ativaPainel", getRootElement(), gerenciaPainel)

addEventHandler ("onClientClick", getRootElement(), function (button, state, absoluteX, absoluteY)
	if (button == "left") and (state == "up") and isDxShowing then
		if isCursorOnElement (860, 401, 101, 22) then -- Fechar
			gerenciaPainel ()
		elseif isCursorOnElement (852, 255, 117, 24) then -- Farda 01
			outputChatBox ("pegou farda 01")
		elseif isCursorOnElement (852, 289, 117, 24) then -- Farda 02
			outputChatBox ("pegou farda 02")
		elseif isCursorOnElement (852, 323, 117, 24) then -- Farda 03
			outputChatBox ("pegou farda 03")
		elseif isCursorOnElement (852, 357, 117, 24) then -- Farda 04
			outputChatBox ("pegou farda 04")
		end
	end
end)

-- Esta é uma Função Útil
function isCursorOnElement( posX, posY, width, height )
	if isCursorShowing( ) then
		local mouseX, mouseY = getCursorPosition( )
		local clientW, clientH = guiGetScreenSize( )
		local mouseX, mouseY = mouseX * clientW, mouseY * clientH
		if ( mouseX > posX and mouseX < ( posX + width ) and mouseY > posY and mouseY < ( posY + height ) ) then
			return true
		end
	end
	return false
end

 

Edited by Lord Henry
  • Thanks 1
Link to comment

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...