Jump to content

BOTAO EM DX!!!!


Recommended Posts

estou voltando aq novamente pois n consegui de jeito nenhum usar o retangulo como botão, vou mandar o codigo e pfv alguem me ajude , me fala onde eu to errando

CLIENT:

local screenW, screenH = guiGetScreenSize()
local mostrar = false
function paineldx()
    if mostrar == true then
    dxDrawRectangle(screenW * 0.3109, screenH * 0.2931, screenW * 0.3781, screenH * 0.4153, tocolor(0, 0, 0, 235), false)
    dxDrawRectangle(screenW * 0.3109, screenH * 0.6764, screenW * 0.3789, screenH * 0.0319, tocolor(0, 89, 173, 254), false)
    dxDrawRectangle(screenW * 0.3102, screenH * 0.2931, screenW * 0.3789, screenH * 0.0319, tocolor(0, 89, 173, 254), false)
    dxDrawLine((screenW * 0.4445) - 1, (screenH * 0.4500) - 1, (screenW * 0.4445) - 1, screenH * 0.5514, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.5555, (screenH * 0.4500) - 1, (screenW * 0.4445) - 1, (screenH * 0.4500) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine((screenW * 0.4445) - 1, screenH * 0.5514, screenW * 0.5555, screenH * 0.5514, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.5555, screenH * 0.5514, screenW * 0.5555, (screenH * 0.4500) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawRectangle(screenW * 0.4445, screenH * 0.4500, screenW * 0.1109, screenH * 0.1014, tocolor(115, 0, 0, 254), false)
    dxDrawText("ARMA", screenW * 0.4437, screenH * 0.4486, screenW * 0.5555, screenH * 0.5514, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
end
end
addEventHandler("onClientRender", root,paineldx)

function mostrardx()
    if mostrar == false then
    showCursor(true)
    mostrar = true
    addEventHandler("onClientRender", root,paineldx)
    else
    showCursor(false)
    mostrar = false
    removeEventHandler("onClientRender", root,paineldx)
    end
end
bindKey("z","down", mostrardx)
function sidearma(button,state)
    if paineldx ==  true then
        if state == "down" then
            if isCursorOnElement(screenW * 0.4445, screenH * 0.4500, screenW * 0.1109, screenH * 0.1014) then
            triggerServerEvent("dararmaevento", localPlayer)
            end
        end
    end
end
addEventHandler("onClientClick", root, sidearma)

SERVER: 

function dararmaaa()
    giveWeapon ( source, 31, 200 )
end
addEvent("dararmaevento", true)
addEventHandler("dararmaevento", root, dararmaaa)

 

Link to comment
7 minutes ago, Murda said:

estou voltando aq novamente pois n consegui de jeito nenhum usar o retangulo como botão, vou mandar o codigo e pfv alguem me ajude , me fala onde eu to errando

CLIENT:


local screenW, screenH = guiGetScreenSize()
local mostrar = false
function paineldx()
    if mostrar == true then
    dxDrawRectangle(screenW * 0.3109, screenH * 0.2931, screenW * 0.3781, screenH * 0.4153, tocolor(0, 0, 0, 235), false)
    dxDrawRectangle(screenW * 0.3109, screenH * 0.6764, screenW * 0.3789, screenH * 0.0319, tocolor(0, 89, 173, 254), false)
    dxDrawRectangle(screenW * 0.3102, screenH * 0.2931, screenW * 0.3789, screenH * 0.0319, tocolor(0, 89, 173, 254), false)
    dxDrawLine((screenW * 0.4445) - 1, (screenH * 0.4500) - 1, (screenW * 0.4445) - 1, screenH * 0.5514, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.5555, (screenH * 0.4500) - 1, (screenW * 0.4445) - 1, (screenH * 0.4500) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine((screenW * 0.4445) - 1, screenH * 0.5514, screenW * 0.5555, screenH * 0.5514, tocolor(0, 0, 0, 255), 1, false)
    dxDrawLine(screenW * 0.5555, screenH * 0.5514, screenW * 0.5555, (screenH * 0.4500) - 1, tocolor(0, 0, 0, 255), 1, false)
    dxDrawRectangle(screenW * 0.4445, screenH * 0.4500, screenW * 0.1109, screenH * 0.1014, tocolor(115, 0, 0, 254), false)
    dxDrawText("ARMA", screenW * 0.4437, screenH * 0.4486, screenW * 0.5555, screenH * 0.5514, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
end
end
addEventHandler("onClientRender", root,paineldx)

function mostrardx()
    if mostrar == false then
    showCursor(true)
    mostrar = true
    addEventHandler("onClientRender", root,paineldx)
    else
    showCursor(false)
    mostrar = false
    removeEventHandler("onClientRender", root,paineldx)
    end
end
bindKey("z","down", mostrardx)
function sidearma(button,state)
    if paineldx ==  true then
        if state == "down" then
            if isCursorOnElement(screenW * 0.4445, screenH * 0.4500, screenW * 0.1109, screenH * 0.1014) then
            triggerServerEvent("dararmaevento", localPlayer)
            end
        end
    end
end
addEventHandler("onClientClick", root, sidearma)

SERVER: 


function dararmaaa()
    giveWeapon ( source, 31, 200 )
end
addEvent("dararmaevento", true)
addEventHandler("dararmaevento", root, dararmaaa)

 

isCursorOnElement nil valor

e pineldx == true ?

pineldx retorna função

tente isso  usando

IsMouseInPosition

adicionar a função ao lado do cliente

e faça-o gostar

local screenW, screenH = guiGetScreenSize()
local mostrar = false

function paineldx()
if mostrar == true then
dxDrawRectangle(screenW * 0.3109, screenH * 0.2931, screenW * 0.3781, screenH * 0.4153, tocolor(0, 0, 0, 235), false)
dxDrawRectangle(screenW * 0.3109, screenH * 0.6764, screenW * 0.3789, screenH * 0.0319, tocolor(0, 89, 173, 254), false)
dxDrawRectangle(screenW * 0.3102, screenH * 0.2931, screenW * 0.3789, screenH * 0.0319, tocolor(0, 89, 173, 254), false)
dxDrawLine((screenW * 0.4445) - 1, (screenH * 0.4500) - 1, (screenW * 0.4445) - 1, screenH * 0.5514, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.5555, (screenH * 0.4500) - 1, (screenW * 0.4445) - 1, (screenH * 0.4500) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine((screenW * 0.4445) - 1, screenH * 0.5514, screenW * 0.5555, screenH * 0.5514, tocolor(0, 0, 0, 255), 1, false)
dxDrawLine(screenW * 0.5555, screenH * 0.5514, screenW * 0.5555, (screenH * 0.4500) - 1, tocolor(0, 0, 0, 255), 1, false)
dxDrawRectangle(screenW * 0.4445, screenH * 0.4500, screenW * 0.1109, screenH * 0.1014, tocolor(115, 0, 0, 254), false)
dxDrawText("ARMA", screenW * 0.4437, screenH * 0.4486, screenW * 0.5555, screenH * 0.5514, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "center", "center", false, false, false, false, false)
end
end
addEventHandler("onClientRender", root,paineldx)

function mostrardx()
if mostrar == false then
showCursor(true)
mostrar = true
addEventHandler("onClientRender", root,paineldx)
else
showCursor(false)
mostrar = false
removeEventHandler("onClientRender", root,paineldx)
end
end
bindKey("z","down", mostrardx)

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

function sidearma(button,state)
if (mostrar == true) and (button == "left") and (state == 'down') then
if isMouseInPosition(screenW * 0.4445, screenH * 0.4500, screenW * 0.1109, screenH * 0.1014) then
triggerServerEvent("dararmaevento", localPlayer)
end
end
end
addEventHandler("onClientClick", root, sidearma)

acho que agora vai dar certo

Link to comment
3 hours ago, Lord Henry said:

Cara, se vc não sabe fazer painel em DX, faça em CEGUI pois é mais fácil.

ue mano kkkkk agora tem q ser assim? se eu n souber fazer algo tenho q desistir dela, painel gui eu sei fazer , mais gui e mt feio e quero algo mais  bonito, pelo menos queria, eu vou dar um tempo em scripting eu acho, vou estudar melhor pra poder fazer algo , mais e isso , mt obg 

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