Jump to content

DASHBOARD


Recommended Posts

ola gente, estou fazendo esse seguinte dashboard aqui, e quero que quando clique em usuario ele mude para outra imagem, e assim em diante nos outros, mas n sei como comecar, alguem pd me ajudar?spacer.png

esse 'e o script ate agr, ele esta correto ate agr

 

--[[

#   #        #       #    # #       #           #      #       #          #
#  #        # #      #    #        # #         #      # #       # #         #
# #        #   #     #    # #     #   #       #      #   #       #   #       #
##        #######    ###### #    #     #     #      #######       #     #     #
# #      #       #   #    # #   #       #   #      #       #       #       #   #
#  #    #         #  #    # #  #         # #      #         #        #         # #
#   #  #           # #    # # #           #      #           #       #           #

      ❖ Scritp Por Kahinan ❖

      ❖ Discord: flying demon angry-?#1622 

]]

local screenW,screenH = guiGetScreenSize()
local resW, resH = 1280, 720 
local x, y =  (screenW/resW), (screenH/resH) 
local components = { "area_name", "radio", "vehicle_name" }

function CroakHud ( ... )
    if (not isPlayerMapVisible()) then

        local Dinheiro = getPlayerMoney(localPlayer)
        local Banco = getElementData(localPlayer, "Bank:Caixa") or "0"
        local Sujo = getElementData(localPlayer, "Dinheiro_AirNewSCR") or "0"
        local vida = math.floor(getElementHealth(getLocalPlayer()))
        local colete = math.floor(getPedArmor(getLocalPlayer()))
        local fome = getElementData(getLocalPlayer(), "hunger") or 100
        local sede = getElementData(getLocalPlayer(), "sede") or 100
        local XP = getElementData(getLocalPlayer(), "Level") or "N/A"
        local tag = getElementData(getLocalPlayer(), "ID") or "N/A"
        local Nick = getPlayerName(getLocalPlayer()) or "SEM NOME"

        dxDrawImage(screenW * 0.1406, screenH * 0.1352, screenW * 0.6870, screenH * 0.7269, "img/dashboard.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
        dxDrawText("$ "..Dinheiro, screenW * 0.3255, screenH * 0.3935, screenW * 0.4000, screenH * 0.4148, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("$ "..Banco, screenW * 0.5036, screenH * 0.3935, screenW * 0.5781, screenH * 0.4148, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText(""..XP, screenW * 0.6802, screenH * 0.3935, screenW * 0.7547, screenH * 0.4148, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("$ "..Sujo, screenW * 0.6802, screenH * 0.6630, screenW * 0.7547, screenH * 0.6843, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("COLETE: "..colete.."%", screenW * 0.5036, screenH * 0.6630, screenW * 0.5781, screenH * 0.6843, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("ID: "..tag, screenW * 0.3255, screenH * 0.6630, screenW * 0.4000, screenH * 0.6843, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)
        dxDrawText("VIDA: "..vida.."%", screenW * 0.5036, screenH * 0.6324, screenW * 0.5781, screenH * 0.6537, tocolor(0, 0, 0, 255), 1.40, "default-bold", "left", "top", false, false, false, false, false)

    end
end



local isDXVisible = false
bindKey ("TAB", "both", function()
    if isDXVisible then
        removeEventHandler( "onClientRender", root, CroakHud )
    else
        addEventHandler( "onClientRender", root, CroakHud )
    end
    isDXVisible = not isDXVisible
end)

function convertNumber ( number )   
    local formatted = number   
    while true do       
        formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2')     
        if ( k==0 ) then       
            break   
        end   
    end   
    return formatted 
end

local screenWidth,screenHeight = guiGetScreenSize()
addEventHandler("onClientResourceStart", resourceRoot,
    function()
        myScreenSource = dxCreateScreenSource ( screenWidth, screenHeight )         
    end
)

 

Link to comment

Use o evento onClientClick junto a função isMouseInPosition em um if para saber se a pessoa clicou no botão, se a pessoa clicar em um botão remova o evento do painel principal e adicione o evento do painel secundário.

Exemplo:

function onClientClick (button, state)
  if state == 'down' then
    if isMouseInPosition (screenW * 0.1406, screenH * 0.1352, screenW * 0.6870, screenH * 0.7269) then --Posição do seu botão
    	addEventHandler('onClientRender', root, painelSecundario)
      	removeEventHandler('onClientRender', root, painelPrimario)
    end
  end
end
addEventHandler ( "onClientClick", getRootElement(), onClientClick )
  
  
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

Se te ajudei deixa um likezin :)

  • Like 1
Link to comment

Cria uma variável de controle, quando voce clicar o no menu lateral setar ela.

if tela == "home" then
  elementos da tela
elseif tela == "usuario" then
  elementos da 
end

Para mostrar a tela que você deseja, tem que implementar isso no render também, caso tenha botões nessas tela também vai ser necessário implementar isso na função de click.

É nois

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