Jump to content

dxDraw... Functions - Help required.


demojoel

Recommended Posts

Hello, today I have been having a problem with the dxDrawText & dxDrawRectangle.

I assign a button to trigger a function which looks similar to this:

  
local screenX, screenY = guiGetScreenSize() 
function example () 
    dxDrawText(getElementData(resourceRoot, "server:1") or "", screenX / 2 + 220, screenY / 2 - 220, 20, 120, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "top", true, false) 
    dxDrawText(getElementData(resourceRoot, "server:2") or "", screenX / 2 + 220, screenY / 2 - 200, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "center", "top", true, false) 
    dxDrawText(getElementData(resourceRoot, "server:3") or "", screenX / 2 + 220, screenY / 2 - 180, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "left", "top", true, true) 
end 
  

Once pressed, the text appears for about 0.01 milliseconds then disappears. I have never encounted this problem before, If anyone has a solution to this, it will be much appreciated.

Link to comment
Guest Guest4401

Its because:

dxDrawText draws a string of text on the screen for one frame. In order for the text to stay visible continuously, you need to call this function with the same parameters on each frame update (see onClientRender).
local screenX, screenY = guiGetScreenSize() 
  
function example2() 
    dxDrawText(getElementData(resourceRoot, "server:1") or "", screenX / 2 + 220, screenY / 2 - 220, 20, 120, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "top", true, false) 
    dxDrawText(getElementData(resourceRoot, "server:2") or "", screenX / 2 + 220, screenY / 2 - 200, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "center", "top", true, false) 
    dxDrawText(getElementData(resourceRoot, "server:3") or "", screenX / 2 + 220, screenY / 2 - 180, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "left", "top", true, true) 
end 
  
function example () 
    addEventHandler("onClientRender",root,example2) 
end 

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