Jump to content

dxDrawText


Newbie

Recommended Posts

Posted
    dxDrawText("STATS", x/1.7, y/3.55, 55, 15, tocolor(255, 255, 255, 255), 0.40, "bankgothic", "left", "top", false, false, false, false, false) 

Is there any way to detect if player clicks on the text ?

Posted
  
buton = guiCreateButton(x/1.7, y/3.55, 55, 15, "Button") 
guiSetAlpha(buton , 0) 
  
 addEventHandler ( "onClientGUIClick", buton,  
function() 
--Blba bla bla 
end) 

Posted
  
buton = guiCreateButton(x/1.7, y/3.55, 55, 15, "Button") 
guiSetAlpha(buton , 0) 
  
 addEventHandler ( "onClientGUIClick", buton,  
function() 
--Blba bla bla 
end) 

@Golanu, he wants for dxDraw not for GUI.

@Newbie i suggest you to create a guiLabel, and then use onClientGUIClick to check when the player click on the label, if you want show a window or a gui element then use guiSetVisible.

Example:

  
local myLabel = guiCreateLabel  ( x, y, width, height, "text", true ) 
local myWindow = guiCreateWindow ( x, y, width, height, "Information", true ) 
guiSetVisible(myWindow, false) 
  
function onClick() 
guiSetVisible(myWindow, true) 
end 
addEventHandler("onClientGUIClick", root, onClick) 

Posted (edited)

Nikolai just don't write if you don't have any clue.

@Newbie, i would recommened you BlanK9's example.

Or you could do some maths:

  
addEventHandler("onClientClick",root, 
    function(b,state) 
        if state == down then -- check if  the state is down , otherwise it triggers this function 2 times (up and down) 
            if isMouseWithinRangeOf(x/1.7,55,y/3.55,15) then -- your dx drawn text. 
                ....-- your code. 
            end 
        end 
end 
) 
                 
  
function isMouseWithinRangeOf(psx,pssx,psy,pssy) 
  if isCursorShowing() == false then 
    return false 
  end 
  local cx,cy = getCursorPosition() 
  cx,cy = cx*x,cy*y 
  if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then 
    return true,cx,cy 
  else 
    return false 
  end 
end 

Hope that helps you.

Edited by Guest
Posted

"onClientClick is more efficient". You don't even need to create any gui element for dx but if you want to make a rectangle or something then use "onClientGUIClick" else its not needed.

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