Jump to content

Scroll Para Painel DX


Recommended Posts

local screenW, screenH = guiGetScreenSize()
local x, y = (screenW/1920), (screenH/1080)

local maxLinhas = 5
local proximaPagina = 0

local garage = {
    state = false,
	number = 1,
	Fonte1 = dxCreateFont("font/lalezar.ttf", x*28),
	Fonte2 = dxCreateFont("font/lalezar.ttf", x*16),
	Fonte3 = dxCreateFont("font/MontserratRegular.ttf", x*14),
	Fonte4 = dxCreateFont("font/Montserrat-Bold.ttf", x*20),
	Fonte5 = dxCreateFont("font/Montserrat-Bold.ttf", x*14),
	Fonte6 = dxCreateFont("font/lalezar.ttf", x*20),
	Car = nil,
	selected = nil,
	Numbers = {},
}

function GaragemPainel ()

	exports['M_Blur']:dxDrawBluredRectangle(screenW * 0.0000, screenH * 0.0000, screenW * 1.0000, screenH * 1.0000, tocolor(255, 255, 255, 255))

	--

	dxDrawRectangle(x*1501, y*0, x*419, y*1080, tocolor(44, 45, 75, 255)) -- Base

	--

	dxDrawRectangle(x*1523, y*27, x*167, y*67, tocolor(47, 176, 52, 255)) -- Butão retirar 
	if isCursorOnElement(x*1523, y*27, x*167, y*67) then
	dxDrawRectangle(x*1523, y*27, x*167, y*67, tocolor(102, 255, 108, 255)) -- Butão retirar 
	end
	dxDrawText('RETIRAR', x*1530, y*27, x*102, y*27, tocolor(255, 255, 255, 255), 1.00, garage.Fonte4, 'left', center, false, false, false, true, false)
	dxDrawText('Veiculo selecionado', x*1530, y*61, x*139, y*19, tocolor(255, 255, 255, 255), 1.00, garage.Fonte3, 'left', center, false, false, false, true, false)

	--

	dxDrawRectangle(x*1735, y*27, x*167, y*67, tocolor(212, 31, 31, 255)) -- Butão guardar 
	if isCursorOnElement(x*1735, y*27, x*167, y*67) then
	dxDrawRectangle(x*1735, y*27, x*167, y*67, tocolor(216, 47, 47, 255)) -- Butão guardar 
	end
	dxDrawText('GUARDAR', x*1744, y*27, x*117, y*44, tocolor(255, 255, 255, 255), 1.00, garage.Fonte4, 'left', center, false, false, false, true, false)
	dxDrawText('Veiculo selecionado', x*1744, y*61, x*139, y*19, tocolor(255, 255, 255, 255), 1.00, garage.Fonte3, 'left', center, false, false, false, true, false)

	--1--

	if config["Viaturas"][1] then

	dxDrawRectangle(x*1523, y*132, x*379, y*152, tocolor(184, 181, 181, 255)) -- Base Grande 1
	dxDrawRectangle(x*1523, y*132, x*379, y*35, tocolor(12, 20, 60, 255)) -- Base Pequena 1

	dxDrawText(config["Viaturas"][1][1], x*1530, y*135, x*77, y*35, tocolor(255, 255, 255, 255), 1.00, garage.Fonte2, 'left', center, false, false, false, true, false)
	
	dxDrawText('Veiculos na Garagem', x*1533, y*174, x*155, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Veiculos fora da Garagem', x*1533, y*198, x*188, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Modelo', x*1533, y*222, x*55, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)
	dxDrawText('Placa', x*1533, y*246, x*32, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)

	dxDrawText((config["Viaturas"][1][3]-vehiclesSpawned[1]), x*169, y*169, x*1880, y*31, tocolor(47, 176, 52, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(vehiclesSpawned[1], x*193, y*193, x*1880, y*31, tocolor(212, 31, 31, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(config['Viaturas'][1][2], x*1853, y*215, x*39, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'left', top, false, false, true, true, false)
	dxDrawText(config[1][1], x*241, y*241, x*1884, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	
	if garage.selected == 1 then
		dxDrawRectangle(x*1523, y*132, x*379, y*152, tocolor(49, 67, 113, 51))
	end

end
	--2--

	if config["Viaturas"][2] then

	dxDrawRectangle(x*1521, y*322, x*379, y*152, tocolor(184, 181, 181, 255)) -- Base Grande 2
	dxDrawRectangle(x*1521, y*322, x*379, y*35, tocolor(12, 20, 60, 255)) -- Base Pequena 2

	dxDrawText(config["Viaturas"][2][1], x*1534, y*325, x*51, y*31, tocolor(255, 255, 255, 255), 1.00, garage.Fonte2, 'left', center, false, false, false, true, false)

	dxDrawText('Veiculos na Garagem', x*1533, y*364, x*155, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Veiculos fora da Garagem', x*1533, y*388, x*188, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Modelo', x*1533, y*412, x*55, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)
	dxDrawText('Placa', x*1533, y*436, x*32, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)

	dxDrawText((config["Viaturas"][2][3]-vehiclesSpawned[1]), x*169, y*364, x*1880, y*31, tocolor(47, 176, 52, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(vehiclesSpawned[1], x*193, y*388, x*1880, y*31, tocolor(212, 31, 31, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(config['Viaturas'][2][2], x*1853, y*412, x*39, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'left', top, false, false, true, true, false)
	dxDrawText(config[1][1], x*241, y*436, x*1884, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	
	if garage.selected == 2 then
		dxDrawRectangle(x*1521, y*322, x*379, y*152, tocolor(49, 67, 113, 51))
	end

end
	--3--


	if config["Viaturas"][3] then

	dxDrawRectangle(x*1521, y*512, x*379, y*152, tocolor(184, 181, 181, 255)) -- Base Grande 3
	dxDrawRectangle(x*1521, y*512, x*379, y*35, tocolor(12, 20, 60, 255)) -- Base Pequena 3

	dxDrawText(config["Viaturas"][3][1], x*1534, y*515, x*51, y*31, tocolor(255, 255, 255, 255), 1.00, garage.Fonte2, 'left', center, false, false, false, true, false)

	dxDrawText('Veiculos na Garagem', x*1533, y*549, x*155, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Veiculos fora da Garagem', x*1533, y*573, x*188, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Modelo', x*1533, y*597, x*55, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)
	dxDrawText('Placa', x*1533, y*621, x*32, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)

	dxDrawText((config["Viaturas"][3][3]-vehiclesSpawned[1]), x*169, y*549, x*1880, y*31, tocolor(47, 176, 52, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(vehiclesSpawned[1], x*193, y*573, x*1880, y*31, tocolor(212, 31, 31, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(config['Viaturas'][3][2], x*1853, y*602, x*39, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'left', top, false, false, true, true, false)
	dxDrawText(config[1][1], x*241, y*626, x*1884, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	
	if garage.selected == 3 then
		dxDrawRectangle(x*1521, y*512, x*379, y*152, tocolor(49, 67, 113, 51))
	end

end
	--4--

	if config["Viaturas"][4] then

	dxDrawRectangle(x*1521, y*702, x*379, y*152, tocolor(184, 181, 181, 255)) -- Base Grande 4
	dxDrawRectangle(x*1521, y*702, x*379, y*35, tocolor(12, 20, 60, 255)) -- Base Pequena 4

	dxDrawText(config["Viaturas"][4][1], x*1534, y*705, x*51, y*31, tocolor(255, 255, 255, 255), 1.00, garage.Fonte2, 'left', center, false, false, false, true, false)

	dxDrawText('Veiculos na Garagem', x*1533, y*744, x*155, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Veiculos fora da Garagem', x*1533, y*768, x*188, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Modelo', x*1533, y*792, x*55, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)
	dxDrawText('Placa', x*1533, y*816, x*32, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)

	dxDrawText((config["Viaturas"][4][3]-vehiclesSpawned[1]), x*169, y*739, x*1880, y*31, tocolor(47, 176, 52, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(vehiclesSpawned[1], x*193, y*763, x*1880, y*31, tocolor(212, 31, 31, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(config['Viaturas'][4][2], x*1853, y*787, x*39, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'left', top, false, false, true, true, false)
	dxDrawText(config[1][1], x*241, y*811, x*1884, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	
	if garage.selected == 4 then
		dxDrawRectangle(x*1523, y*702, x*379, y*152, tocolor(49, 67, 113, 51))
	end

end
	--5--

	if config["Viaturas"][5] then

	dxDrawRectangle(x*1521, y*892, x*379, y*152, tocolor(184, 181, 181, 255)) -- Base Grande 5
	dxDrawRectangle(x*1521, y*892, x*379, y*35, tocolor(12, 20, 60, 255)) -- Base Pequena 5

	dxDrawText(config["Viaturas"][5][1], x*1534, y*895, x*51, y*31, tocolor(255, 255, 255, 255), 1.00, garage.Fonte2, 'left', center, false, false, false, true, false)

	dxDrawText('Veiculos na Garagem', x*1533, y*934, x*155, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Veiculos fora da Garagem', x*1533, y*958, x*188, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', top, false, false, true, true, false)
	dxDrawText('Modelo', x*1533, y*982, x*55, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)
	dxDrawText('Placa', x*1533, y*1006, x*32, y*17, tocolor(55, 55, 57, 255), 1.00, garage.Fonte5, 'left', center, false, false, true, true, false)

	dxDrawText((config["Viaturas"][5][3]-vehiclesSpawned[1]), x*169, y*929, x*1880, y*31, tocolor(47, 176, 52, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(vehiclesSpawned[1], x*193, y*953, x*1880, y*31, tocolor(212, 31, 31, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)
	dxDrawText(config['Viaturas'][5][2], x*1853, y*977, x*39, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'left', top, false, false, true, true, false)
	dxDrawText(config[1][1], x*241, y*1001, x*1884, y*31, tocolor(12, 20, 60, 255), 1.00, garage.Fonte6, 'right', top, false, false, true, true, false)

	if garage.selected == 5 then
		dxDrawRectangle(x*1523, y*892, x*379, y*152, tocolor(49, 67, 113, 51))
	end

end
	--0--

end

	--

function AbrirGaragem (v) -- função abrir painel
	if garage.state == false then
		vehiclesSpawned = v
		addEventHandler ( "onClientRender", root, GaragemPainel )
		garage.state = true
		showCursor ( true )
		showChat (false)
		playSoundFrontEnd ( 32 )
	end
end
addEvent("openVTR"..config[1][1], true)
addEventHandler("openVTR"..config[1][1], root, AbrirGaragem)


function close() -- função fechar painel
	removeEventHandler ( "onClientRender", root, GaragemPainel )
	garage.state = false
	showCursor ( false )
	showChat (true)
	playSoundFrontEnd ( 32 )
end

function GaragemFuncoes (_,state)
	if garage.state == true then
		if state == "down" then
			if isCursorOnElement(x*1523, y*132, x*379, y*152) then -- veiculo 1
				if config["Viaturas"][1] then
					garage.selected = 1
				end
			elseif isCursorOnElement(x*1523, y*322, x*379, y*152) then -- veiculo 2
				if config["Viaturas"][2] then
					garage.selected = 2
				end
			elseif isCursorOnElement(x*1523, y*512, x*379, y*152) then -- veiculo 3
				if config["Viaturas"][3] then
					garage.selected = 3
				end
			elseif isCursorOnElement(x*1523, y*702, x*379, y*152) then -- veiculo 4
				if config["Viaturas"][4] then
					garage.selected = 4
				end
			elseif isCursorOnElement(x*1523, y*892, x*379, y*152) then -- veiculo 5
				if config["Viaturas"][5] then
					garage.selected = 5
				end
			elseif isCursorOnElement(x*1523, y*27, x*167, y*67) then -- butão retirar
				if garage.selected >= 1 and garage.selected <= 5 then
					triggerServerEvent("functionVTR"..config[1][1], localPlayer, localPlayer, {"spawnVtr", garage.selected})
					close()
				end
			--elseif isCursorOnElement(x*851, y*725, x*217, y*48) then -- butão fechar
				--close()
			elseif isCursorOnElement(x*1735, y*27, x*167, y*67) then -- butão guardar
				if garage.selected >= 1 and garage.selected <= 5 then
					triggerServerEvent("functionVTR"..config[1][1], localPlayer, localPlayer, {"deleteVtr", garage.selected})
					close()
				end
			end
		end
	end
end
addEventHandler ("onClientClick", root, GaragemFuncoes )
bindKey( "backspace", "down", close ) 

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

Queria adicionar Scroll para puder adicionar mais Viaturas mas não estou conseguindo cabe 5 viaturas mas quero colocar 20 com scroll.

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