Sign in to follow this  
Lloyd Logan

dxDrawText

Recommended Posts

Why does this instantly delete the text?

function drawText() 
        dxDrawText("You have successfully bought a vehicle!", 92, 158, 720, 195, tocolor(65, 205, 4, 255), 1.40, "pricedown", "left", "top", false, false, true, false, false) 
        setTimer ( function() 
        triggerEvent("destroy") 
    end, 5000, 1 ) 
    end 
addEvent("drawSuccess", true) 
addEventHandler("drawSuccess", root, drawText) 
  
  
function destroyText() 
    removeEventHandler("drawSuccess", getRootElement(), drawText) 
end 
addEvent("destroy", true) 
addEventHandler("destroy", root, destroyText) 

Share this post


Link to post
What do you mean?

As soon as the it draws the text, it disappears almost extremely quickly (like .5 seconds).

Share this post


Link to post

You can't use dxDrawText without onClientRender/onClientPreRender/onClientHUDRender.

Share this post


Link to post
You can't use dxDrawText without onClientRender/onClientPreRender/onClientHUDRender.

So how could I trigger it at a specific time?

Share this post


Link to post
You add the event handler to render it.

But if I were to do onClientRender wouldn't it show as soon as the player joins? Instead of when I trigger it?

Share this post


Link to post

you can make like this

function drawText() -- draw text 
        dxDrawText("You have successfully bought a vehicle!", 92, 158, 720, 195, tocolor(65, 205, 4, 255), 1.40, "pricedown", "left", "top", false, false, true, false, false) 
addEventHandler("onClientRender", root, drawText) 
  
 setTimer (removeEventHandler, 5000, 1, "onClientRender", getRootElement(), drawText) -- remove text 

OR

use Textdisplay

Share this post


Link to post
If you add the event only when you need to, then no.

Wait so I don't need to use addEventHandler within a function until I want to?

Share this post


Link to post
function renderMyText ( ) 
    dxDrawText ( arguments ) 
end 
  
addCommandHandler ( "render", 
    function ( ) 
        addEventHandler ( "onClientRender", root, renderMyText ) -- Begin rendering our text  
    end 
) 
  
addCommandHandler ( "stoprender", 
    function ( ) 
        removeEventHandler ( "onClientRender", root, renderMyText ) -- Stop rendering our text  
    end 
) 

That's an example.

Share this post


Link to post
function renderMyText ( ) 
    dxDrawText ( arguments ) 
end 
  
addCommandHandler ( "render", 
    function ( ) 
        addEventHandler ( "onClientRender", root, renderMyText ) -- Begin rendering our text  
    end 
) 
  
addCommandHandler ( "stoprender", 
    function ( ) 
        removeEventHandler ( "onClientRender", root, renderMyText ) -- Stop rendering our text  
    end 
) 

That's an example.

Thank you! All is working.

Share this post


Link to post

Line 13: addEventHandler should be removeEventHandler to stop rendering the text.

Share this post


Link to post
Line 13: addEventHandler should be removeEventHandler to stop rendering the text.

Yeah, I only used his example as a guideline, so all is good, thanks though!

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.