Jump to content

[RESOLVIDO]Help Painel DX


Recommended Posts

Galera quando eu inicio o painel em dx nas resources , e clico aonde o "isMouseInPosition" indica sem digitar o comando necessário para abrir-lo , ele pega o veículo , alguem mim ajuda sou novo em DX'S

function pm() 
    dxDrawRectangle(541, 215, 258, 352, tocolor(0, 0, 0, 179), false) 
    dxDrawRectangle(540, 213, 259, 29, tocolor(129, 0, 0, 254), false) 
    dxDrawText("Painel da Policia", 539, 212, 799, 242, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawRectangle(538, 562, 159, 0, tocolor(255, 255, 255, 255), false) 
    dxDrawRectangle(540, 524, 259, 28, tocolor(129, 0, 0, 254), false) 
    dxDrawText("Script Criado Por : +Stronger", 538, 521, 799, 552, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawRectangle(553, 284, 98, 79, tocolor(129, 0, 0, 254), false)   -- Viatura 
    dxDrawRectangle(691, 284, 98, 79, tocolor(129, 0, 0, 254), false)   -- Skin 
    dxDrawRectangle(691, 403, 98, 79, tocolor(129, 0, 0, 254), false)   -- Vida/Colete 
    dxDrawRectangle(551, 403, 98, 79, tocolor(129, 0, 0, 254), false)   -- Armas 
    dxDrawText("Viatura", 552, 281, 651, 363, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("Skin", 690, 281, 789, 363, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("Vida\n Colete", 690, 400, 789, 482, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("Armas", 551, 400, 650, 482, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("X", 755, 244, 789, 274, tocolor(209, 0, 0, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false) 
end 
  
function iniciarRenderizacao ( ) 
    addEventHandler("onClientRender", root, pm) 
    showCursor(true) 
end 
addCommandHandler("tut1", iniciarRenderizacao) 
  
------------------------------------------------------------------- 
  
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 ) 
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then 
        return true 
    else 
        return false 
    end 
end 
  
addEventHandler ( "onClientClick", root, 
    function ( _, state ) 
        if state == "down" then 
            -- Viatura 
            if isMouseInPosition ( 553, 284, 98, 79 ) then 
                triggerServerEvent ( "darAuto", getLocalPlayer() ) 
            
            -- Skin 
            elseif isMouseInPosition ( 691, 284, 98, 79 ) then 
                triggerServerEvent ( "onGreetinC", getLocalPlayer() ) 
            
            -- Vida / Colete 
            elseif isMouseInPosition ( 691, 403, 98, 79 ) then 
                triggerServerEvent ( "VidaColete", getLocalPlayer() ) 
            
            -- Armas 
            elseif isMouseInPosition ( 551, 403, 98, 79 ) then 
                triggerServerEvent ( "onGreeting", getLocalPlayer() ) 
            
            -- Fechar 
            elseif isMouseInPosition ( 755, 244, 34, 30 ) then 
                removeEventHandler ( "onClientRender", root, pm ) 
                showCursor ( false ) 
            end 
        end 
    end 
) 

Edited by Guest
Link to comment

Define uma variável que indica se o DX está mostrando ou não e use-a no evento onClientClick.

Assim:

local g_isDXVisible = false 
  
function pm() 
    dxDrawRectangle(541, 215, 258, 352, tocolor(0, 0, 0, 179), false) 
    dxDrawRectangle(540, 213, 259, 29, tocolor(129, 0, 0, 254), false) 
    dxDrawText("Painel da Policia", 539, 212, 799, 242, tocolor(255, 255, 255, 255), 0.80, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawRectangle(538, 562, 159, 0, tocolor(255, 255, 255, 255), false) 
    dxDrawRectangle(540, 524, 259, 28, tocolor(129, 0, 0, 254), false) 
    dxDrawText("Script Criado Por : +Stronger", 538, 521, 799, 552, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawRectangle(553, 284, 98, 79, tocolor(129, 0, 0, 254), false)   -- Viatura 
    dxDrawRectangle(691, 284, 98, 79, tocolor(129, 0, 0, 254), false)   -- Skin 
    dxDrawRectangle(691, 403, 98, 79, tocolor(129, 0, 0, 254), false)   -- Vida/Colete 
    dxDrawRectangle(551, 403, 98, 79, tocolor(129, 0, 0, 254), false)   -- Armas 
    dxDrawText("Viatura", 552, 281, 651, 363, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("Skin", 690, 281, 789, 363, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("Vida\n Colete", 690, 400, 789, 482, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("Armas", 551, 400, 650, 482, tocolor(255, 255, 255, 255), 0.75, "bankgothic", "center", "center", false, false, false, false, false) 
    dxDrawText("X", 755, 244, 789, 274, tocolor(209, 0, 0, 254), 1.00, "bankgothic", "center", "center", false, false, false, false, false) 
end 
  
function iniciarRenderizacao ( ) 
    addEventHandler("onClientRender", root, pm) 
    g_isDXVisible = true 
    showCursor(true) 
end 
addCommandHandler("tut1", iniciarRenderizacao) 
  
------------------------------------------------------------------- 
  
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 ) 
    if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then 
        return true 
    else 
        return false 
    end 
end 
  
addEventHandler ( "onClientClick", root, 
    function ( _, state ) 
        if state == "down" and g_isDXVisible and not isConsoleActive() and not isMTAWindowActive() then 
            -- Viatura 
            if isMouseInPosition ( 553, 284, 98, 79 ) then 
                triggerServerEvent ( "darAuto", getLocalPlayer() ) 
            
            -- Skin 
            elseif isMouseInPosition ( 691, 284, 98, 79 ) then 
                triggerServerEvent ( "onGreetinC", getLocalPlayer() ) 
            
            -- Vida / Colete 
            elseif isMouseInPosition ( 691, 403, 98, 79 ) then 
                triggerServerEvent ( "VidaColete", getLocalPlayer() ) 
            
            -- Armas 
            elseif isMouseInPosition ( 551, 403, 98, 79 ) then 
                triggerServerEvent ( "onGreeting", getLocalPlayer() ) 
            
            -- Fechar 
            elseif isMouseInPosition ( 755, 244, 34, 30 ) then 
                removeEventHandler ( "onClientRender", root, pm ) 
                g_isDXVisible = false 
                showCursor ( false ) 
            end 
        end 
    end 
) 

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