Jump to content

onClientClick help.


Xeno

Recommended Posts

Posted

I'm working with dxDraw now, and I'm trying to make it so you can press a piece of text so it triggers something else.

I neally got it to work, but I need it so it works when I click on the dxDrawText, because at the moment, the GUI appears when I click anywhere on the screen. Please help me.

dxDrawText ( "Chheseseseses", 050, screenHeight - 530, screenWidth, screenHeight, tocolor ( 0,0,0, 255 ), 5,  "sans" ) 

function news(clickedElement) 
if (clickedElement) then 
addEventHandler("onClientRender",rootElement, serverBoxDesign)  
end 
end 
addEventHandler ( "onClientClick", getRootElement(), news ) 

Posted

You are triggering the event onClientClick, if you don't insert an if statement for check what you've clicked it will show the text always, do like this:

function news(clickedElement) 
if (clickedElement == something) then 
addEventHandler("onClientRender",rootElement, serverBoxDesign) 
end 
end 
addEventHandler ( "onClientClick", getRootElement(), news ) 

You want that when you click on something like a text it shows another text? You must repleace "something" in the if whit the text name, and (i think) it will work :D

Posted

lol, you can't replace "something" with the text name. You have to replace with the variable. In this case you have to use an alternative dx text drawing system that you can set a variable to or use gui label ( or other you want ).

Posted
The first argument of "onClientClick" is the mouse button pressed, not the world element clicked.
function news(clickedElement) 
if (clickedElement == login) then 
addEventHandler("onClientRender",rootElement, serverBoxDesign) 
end 
end 
addEventHandler ( "onClientClick", down, news ) 

Error: Bad arguement @ "addEventHandler" [Expected Element at arguement, 2 got nil]

Posted

You want to detect when click on a GUI element? if so use "onClientGUIClick".

function news(_,_,_,_,_,_,_,clickedElement) 
if (clickedElement == login) then 
addEventHandler("onClientRender",rootElement, serverBoxDesign) 
end 
end 
addEventHandler ( "onClientClick", root, news ) 

Posted

onClientClick doesn't work for DX drawing, you must make your own event.

You can use

getCursorPosition  

to compare the position of the DX drawing with the mouse.

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