Lloyd Logan Posted January 16, 2014 Posted January 16, 2014 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!
Castillo Posted January 16, 2014 Posted January 16, 2014 What do you mean? San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Forrest Posted January 16, 2014 Posted January 16, 2014 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
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Castillo Posted January 16, 2014 Posted January 16, 2014 You can't use dxDrawText without onClientRender/onClientPreRender/onClientHUDRender. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Castillo Posted January 16, 2014 Posted January 16, 2014 You add the event handler to render it. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Castillo Posted January 16, 2014 Posted January 16, 2014 If you add the event only when you need to, then no. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
WASSIm. Posted January 16, 2014 Posted January 16, 2014 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
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Castillo Posted January 16, 2014 Posted January 16, 2014 Well, I thought that was obvious. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Castillo Posted January 16, 2014 Posted January 16, 2014 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. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 16, 2014 Author Posted January 16, 2014 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!
Sasu Posted January 16, 2014 Posted January 16, 2014 Line 13: addEventHandler should be removeEventHandler to stop rendering the text. State: Inactive
Lloyd Logan Posted January 17, 2014 Author Posted January 17, 2014 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!
Castillo Posted January 17, 2014 Posted January 17, 2014 My mistake, fixed. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now