Jump to content

Ajudaaa


Recommended Posts

Posted
Alguem por favor me ajuda como eu crio botao em dx?

Olá Rafael.

este script aqui ele tem um botão para fechar o painel, que será aberto

baixe ele e dê uma estudada nele; são poucas linhas, e acho que será mais fácil para você que é iniciante.

( lendo os códigos e vendo o funcionamento dele, será mais fácil aprender. assim como eu fiz :roll: )

http://multitheftautovc.blogspot.com.br ... aviso.html

 DUyJ810.gif

Posted
Alguem por favor me ajuda como eu crio botao em dx?

Olá Rafael.

este script aqui ele tem um botão para fechar o painel, que será aberto

baixe ele e dê uma estudada nele; são poucas linhas, e acho que será mais fácil para você que é iniciante.

( lendo os códigos e vendo o funcionamento dele, será mais fácil aprender. assim como eu fiz :roll: )

http://multitheftautovc.blogspot.com.br ... aviso.html

Hm acabei de ver aqui estava tentando axar um painel com botao em dx mas todos estao compilado e esse nao esta eu vi que na verdade nao e um botao do guieditor e botao que nao aparece ...

Daqui pra frente vai ser tudo diferente ♫ ♩

Posted

Fiz um código básico que cria um botão em DX, usando um retângulo (em DX) e um texto.

Deixei algumas coisas explicadas com comentários no código:

local sw,sh = guiGetScreenSize() 
-- Tamanho e posicionamento 
local DXBtn = {} 
local largura, altura = 100, 40 
DXBtn.left = (sw - largura) /2 -- Posição X 
DXBtn.top = (sh - altura) /2 -- Posição Y 
-- Os cálculos que fiz, é só pra centralizar 
  
addEvent( "onClientDXButtonClick" ) 
  
function drawMyDXButton() 
  -- Retângulo e texto 
  dxDrawRectangle( DXBtn.left, DXBtn.top, largura, altura, tocolor(0,0,0,160), false ) 
  dxDrawText( "Botão em DX", DXBtn.left, DXBtn.top, DXBtn.left + largura, DXBtn.top + altura, 
            tocolor(255, 255, 255), 1.2, "arial", "center", "center" ) 
end 
  
addEventHandler( "onClientResourceStart", resourceRoot, 
    function() 
        showCursor(true) 
        addEventHandler( "onClientClick", root, onButtonClick ) -- Evento para manipular o clique 
        addEventHandler( "onClientRender", root, drawMyDXButton ) -- Renderizar o DX 
    end 
) 
  
function onButtonClick() 
    if (button == "left") and (state == "up") and not isConsoleActive() and not isMainMenuActive() then 
        -- Verificando se o cursor está sobre o DX 
        if isMouseWithinRangeOf(DXBtn.left, largura, DXBtn.top, altura) then 
            -- Chamando um evento personalizado, 
            -- que será chamado sempre que clicar no 'botão' 
            return triggerEvent( "onClientDXButtonClick", resourceRoot ) 
        end 
    end 
end 
  
addEventHandler( "onClientDXButtonClick", root, 
    function () 
        -- O evento foi chamado, isto significa que, 
        -- o jogador clicou no botão em DX 
        outputChatBox("O botão em DX foi clicado!", 0,230,0) 
        -- Se quiser remover o botão: 
        showCursor(false) 
        removeEventHandler( "onClientRender", root, drawMyDXButton ) 
        -- Se quiser remove também o evento "onClientClick", 
        -- e o adiciona denovo quando for mostrar o DX novamente 
    end 
) 
  
-- Esta função verifica se o mouse está num local da tela 
function isMouseWithinRangeOf(psx,pssx,psy,pssy) 
    if not isCursorShowing() then return false end; 
    local cx,cy = getCursorPosition() 
    cx,cy = cx*sw,cy*sh 
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then 
        return true 
    end 
    return false 
end 

Só não sei se vai rodar no servidor sem dar erro, já que não testei. Mas você pode procurar entender como funciona e tentar aprender como fazer.

Please do not PM me with scripting related question nor support, use the forums instead.

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