Jump to content

isCursorOnPosition


Recommended Posts

Boa Tarde, estou desenvolvendo um script de loja de armas ilegais, mas , quando coloco as coordenadas do isCursorOnPosition no client, ele não fica alinhado com as coordenadas igual do rectangleDX, alguém poderia me ajudar?

 

Edit: desculpem pelo nome inapropriado da função, mas foi meu amigo que me tentou ajudar e ele colocou assim o nome da função (não levem a mal rsrs)

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

theMarker = createMarker(2796.24805, -2373.49243, 13.63160-1.1, "cylinder", 1, 255, 0, 0, 255)

function botones()


    local botonCerrar = guiCreateButton(1207, 238, 38, 34,"",false)
     guiSetAlpha(botonCerrar,0)
 

    addEventHandler("onClientGUIClick",botonCerrar,
    function()
    removeEventHandler("onClientRender",root,estructuraDX)
    removeEventHandler("onClientRender",root,estructura)
    removeEventHandler("onClientRender",root,lettersdx)
    guiSetVisible(botonCerrar,false)
    showCursor(false)
    end)

addEventHandler("onClientGUIClick",botonDar,
function()
local dinero = guiGetText(editDinero) 
local skin = guiGetText(editSkin)
triggerServerEvent("valores",localPlayer,dinero,skin)
end)
    -------------
    
end




function estructuraDX2(hitPlayer, matchingdimension)
    if (hitPlayer == localPlayer) then
        addEventHandler("onClientRender", root, estructuraDX)
        addEventHandler("onClientRender", root, estructura)
        addEventHandler("onClientRender", root, lettersdx)
        addEventHandler("onClientRender", root, meupaudeoculos)
        botones()
        render = true
        showCursor(true)
    end
end
addEventHandler ("onClientMarkerHit", theMarker, estructuraDX2)

function lettersdx()
    dxDrawText("DESERT EAGLE", 671, 328, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("SHOTGUN", 671, 528, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("UZI", 671, 728, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("AK47", 671, 928, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("PRECOS", 1371, 258, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("ARMAS", 671, 258, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("R$12000", 1371, 328, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("R$18000", 1371, 528, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("R$16000", 1371, 728, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
    dxDrawText("R$28000", 1371, 928, 883, 367, tocolor(255, 255, 255, 255), 1.20, "default-bold", "center", "center", false, false, false, false, false)
end
function estructura()

        if not cursorPosition( 692, 428, 529, 41 ) then
        dxDrawRectangle(692, 428, 529, 41, tocolor(14, 10, 10, 152), false)
        else
        dxDrawRectangle(692, 428, 529, 41, tocolor(255, 0, 0, 80), false)
        end

        if not cursorPosition( 692, 328, 529, 41 ) then
        dxDrawRectangle(692, 328, 529, 41, tocolor(14, 10, 10, 152), false)
        else
        dxDrawRectangle(692, 328, 529, 41, tocolor(255, 0, 0, 80), false)
        end
                if not cursorPosition( 692, 528, 529, 41 ) then
        dxDrawRectangle(692, 528, 529, 41, tocolor(14, 10, 10, 152), false)
        else
        dxDrawRectangle(692, 528, 529, 41, tocolor(255, 0, 0, 80), false)
        end
                        if not cursorPosition( 692, 628, 529, 41 ) then
        dxDrawRectangle(692, 628, 529, 41, tocolor(14, 10, 10, 152), false)
        else
        dxDrawRectangle(692, 628, 529, 41, tocolor(255, 0, 0, 80), false)
        end
                if not cursorPosition( 1207, 238, 38, 34 ) then
        dxDrawRectangle(1207, 238, 38, 34, tocolor(14, 10, 10, 152), false)
        else
        dxDrawRectangle(1207, 238, 38, 34, tocolor(255, 0, 0, 80), false)
        end
end

function estructuraDX()
        dxDrawRectangle(665, 238, 581, 546, tocolor(1, 0, 0, 124), false)
        dxDrawLine(664, 273, 1245, 273, tocolor(253, 0, 0, 124), 2, false)
        dxDrawText("SHOP ARMAS ILEGAIS", 764, 236, 1129, 273, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("SHOP ARMAS ILEGAIS", 764, 236, 1129, 273, tocolor(255, 255, 255, 255), 2.00, "default", "center", "center", false, false, false, false, false)
        dxDrawText("X", 1206, 236, 1245, 272, tocolor(231, 0, 0, 254), 2.00, "default", "center", "center", false, false, false, false, false)

end

function meupaudeoculos(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement)
if ( clickedElement ) then
if (button == "left" and state == "up") then 
if isCursorOnElement ( 694, 327, 525, 42 ) then -- AK
triggerServerEvent ("comprarak",getLocalPlayer(),comprarak)
end
end
end
end

addEventHandler ( "onClientClick", getRootElement(), meupaudeoculos )


----------------------------------------
function cursorPosition(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

----------------------------------------------------------------------------------------------------------------------------------------

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

 

Edited by mesadown
Link to comment
  • Other Languages Moderators
Quote

dxDrawRectangle(665, 238, 581, 546, tocolor(1, 0, 0, 124), false)
if isCursorOnElement (694, 327, 525, 42) then

Não faz sentido você verificar com valores diferentes dos valores usados pra criar o DX.

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