Jump to content

dx draw


Castillo

Recommended Posts

You either draw it, or you don't. That's something you can choose pretty easily onClientRender.

I used this to show it but how i can do to hide etc with only 1 key, this is what i used

function show_dx ()
addEventHandler("onClientRender",rootElement, create2DRectangle)
showCursor(true)
end
bindKey ( "m", "down", show_dx )

Link to comment

global variable:

handlerExist = false
 
function show_dx ()
if (handlerExist) then
removeEventHandler("onClientRender",rootElement, create2DRectangle)
     handlerExist = false
showCursor(false)
else
addEventHandler("onClientRender",rootElement, create2DRectangle)
     handlerExist = true
showCursor(true)
end
end
bindKey ( "m", "down", show_dx )

Link to comment
global variable:
handlerExist = false
 
function show_dx ()
if (handlerExist) then
removeEventHandler("onClientRender",rootElement, create2DRectangle)
     handlerExist = false
showCursor(false)
else
addEventHandler("onClientRender",rootElement, create2DRectangle)
     handlerExist = true
showCursor(true)
end
end
bindKey ( "m", "down", show_dx )

Thank you very much, this worked perfect, now i can continue learning dx :D

Edit: btw, someone of us know how i could make a button like i do in gui? but with dx funtions.

Link to comment
Edit: btw, someone of us know how i could make a button like i do in gui? but with dx funtions.

onClientClick

Or you could use dxGUIElements functions I have in one of my resources (scripts/client/dxGUI for needed scripts and scripts/client/Spawnscreen.lua for example usage)

Example usage:

addDXGUIElement({
info = {parent = "aContainer", priority	= 2, type = "text", id = "teamTitle"},
normalData = {text = "Team", left = 10, top = 10, color = tocolor(255,255,255), scale = 1.2, font = "default-bold", postGUI = true},
hoverData = {color = tocolor(100,100,100)} -- change colour on mouse hover
})

parent is a common parent element, or string of whatever, so you could later do:

makeDXGUIVisible("aContainer", true) (true means that cursor is also shown)

Also, you could specify activeData, which will be used, when button has been clicked on, or you can manually change DXGUIElement state to active with

changeGUIElementActive(info, boolean state), where info is a table containing the parent, priority, type and id keys. If state is true, element will be changed to active state (for whatever reason you want to), or when false then to deactive=normal state.

You can also add to normalData func and funcAttributes, so that when "button" is clicked, func(funcAttributes) will be called, btw put the functions you want to use there before making the GUI elements (or add filename before GUI functions in meta.xml), because the func is added by reference (just check the example in Spawnscreen.lua).

Also, you can add sound for hover and click events (again, check the example usage in Spawnscreen.lua).

Link to comment
Edit: btw, someone of us know how i could make a button like i do in gui? but with dx funtions.

onClientClick

Or you could use dxGUIElements functions I have in one of my resources (scripts/client/dxGUI for needed scripts and scripts/client/Spawnscreen.lua for example usage)

Example usage:

addDXGUIElement({
info = {parent = "aContainer", priority	= 2, type = "text", id = "teamTitle"},
normalData = {text = "Team", left = 10, top = 10, color = tocolor(255,255,255), scale = 1.2, font = "default-bold", postGUI = true},
hoverData = {color = tocolor(100,100,100)} -- change colour on mouse hover
})

parent is a common parent element, or string of whatever, so you could later do:

makeDXGUIVisible("aContainer", true) (true means that cursor is also shown)

Also, you could specify activeData, which will be used, when button has been clicked on, or you can manually change DXGUIElement state to active with

changeGUIElementActive(info, boolean state), where info is a table containing the parent, priority, type and id keys. If state is true, element will be changed to active state (for whatever reason you want to), or when false then to deactive=normal state.

You can also add to normalData func and funcAttributes, so that when "button" is clicked, func(funcAttributes) will be called, btw put the functions you want to use there before making the GUI elements (or add filename before GUI functions in meta.xml), because the func is added by reference (just check the example in Spawnscreen.lua).

Also, you can add sound for hover and click events (again, check the example usage in Spawnscreen.lua).

Thanks, i will take a look right now.

Link to comment

info.priority is zIndex btw, so that if there are two elements overlapping, you can specify which one will be over other one (e.g on spawnscreen I have grey rectangle as a background for the gun image (so gun image has larger priority (or was it other way around?), and gray rectangle has the func when clicked). Also all the paramaters (font, etc) are optional, as there are default set already.

EDIT: Also, by default it changes accordingly to the resolution, if not stated otherwise, and the "workspace" is 800x600, so think in that resolution (if you put somethings' x position to 800 there and your screen resolution is 1024*whatever, the x will be 1024).

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