Jump to content

dxDrawText


Lloyd Logan

Recommended Posts

Posted

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) 

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

What do you mean?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
What do you mean?

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

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted
dxDraw functions are only drawn for ONE frame, thus needing to work in conjunction with an event such as onClientRender or onClientPreRender in order to draw them every frame.

Check the wiki for an example @ https://wiki.multitheftauto.com/wiki/DxDrawText

Ah, I understand! So how would I trigger them (not using the render?)

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

So how could I trigger it at a specific time?

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

You add the event handler to render it.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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?

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Omerta Roleplay

Posted
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?

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

Well, I thought that was obvious.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Well, I thought that was obvious.

I never thought of it to be honest! Thanks!

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted
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!

If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE

SCOTLAND, my hometown, and the Home of GTA!

Posted

My mistake, fixed.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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