Jump to content

Problem with dx clicking


papam77

Recommended Posts

Hello,

can you tell me with this does not work?

When I click to button nothing happend it has to say ,,true"

local sX, sY = guiGetScreenSize() 
  
function test2 () 
dxDrawRectangle(sX/4, sY/4, sX/8, sY/8, tocolor(0,255,0,255), false) 
showCursor(true) 
end 
addEventHandler("onClientRender", root, test2 ) 
  
function test ( button, state, x, x ) 
if (button == 'left' or button == 'right' or state == 'down') then 
local checkX = ( x > sX/4 and x < sX/8 ) 
local checkY = ( y > sY/4 and y < sY/8 ) 
  
if ( checkX and checkY ) then 
outputChatBox("true") 
end 
end 
end 
addEventHandler("onClientClick", getResourceRootElement(getThisResource()), test) 

Link to comment

You had a few mistakes. Try this:

local sX, sY = guiGetScreenSize() 
  
function test2 () 
    dxDrawRectangle(sX/4, sY/4, sX/8, sY/8, tocolor(0,255,0,255), false) 
    showCursor(true) 
end 
addEventHandler("onClientRender", root, test2 ) 
  
function test ( button, state, x, y ) 
    if (button == 'left' or button == 'right' or state == 'down') then 
        local checkX = ( x > sX/4 and x < 2*sX/4-sX/8 ) 
        local checkY = ( y > sY/4 and y < 2*sY/4-sY/8 ) 
          
        if ( checkX and checkY ) then 
            outputChatBox("true") 
        end 
    end 
end 
addEventHandler("onClientClick", root, test) 

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