Jump to content

onClientClick - Weaponshop problem


itHyperoX

Recommended Posts

Hi, i made a weaponshop it working full dxdraw.

The problem is, when i click on my screen, but i'm not in the weaponshop marker i can buy a weapons from there.

 

addEventHandler("onClientClick", root, function(key, state, cx, cy)
        if key == "left" and state == "down" then
            if isCursorInBox(screenW * 0.3302, screenH * 0.3500, screenW * 0.0620, screenH * 0.0370) then
             triggerServerEvent("giveM4",getLocalPlayer(),giveM4)
            end
        end
end)



addEventHandler("onClientClick", root, function(key, state, cx, cy)
        if key == "left" and state == "down" then
            if isCursorInBox(screenW * 0.5333, screenH * 0.5667, screenW * 0.0344, screenH * 0.0296) then
            removeEventHandler("onClientPreRender", getRootElement(), draw)
            showCursor(false)
            end
        end
end)



function isCursorInBox(left, top, width, height)
    if isCursorShowing() then
        cursorX, cursorY = getCursorPosition()
        cursorX, cursorY = cursorX*screenW, cursorY*screenH
        if cursorX >= left and cursorX <= left+width and cursorY >= top and cursorY <= top+height then
            return true
        end
    else
        return false
    end
  
  addEventHandler("onClientMarkerHit", shopmarker,
function (p)
    if p == localPlayer then
        addEventHandler("onClientPreRender", getRootElement(), draw)
        showCursor(true)
    end
end
)

So.

What i need to do, only the clicks work, when i'm on the marker ?

If need, i can post the full client side.

 

 

 

Edited by TheMOG
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...