MoeezKhan Posted January 29, 2014 Share Posted January 29, 2014 anybody tell me what is wrong dxDrawText not working. function dxDrawText() createdxDrawText = ("criminal", "2035.3903808594, 1349.2917480469, 10.8203125", 255, 0, 0) bindKey = ("F11", "down", "dxDrawText") addEventHander("onResourcesStart", getRootElement(), dxDrawText) Link to comment
Karuzo Posted January 29, 2014 Share Posted January 29, 2014 What are you doing? There is no function like createdxDrawText, btw what shoudl "criminal" and this coordinates be? Link to comment
MoeezKhan Posted January 29, 2014 Author Share Posted January 29, 2014 i can't understand Link to comment
Karuzo Posted January 29, 2014 Share Posted January 29, 2014 Wiki : https://wiki.multitheftauto.com/wiki/DxDrawText Try this( don't forget to write the x, y, width and height numbers) : local screenW, screenH = guiGetScreenSize() function drawName() dxDrawText("Criminal",x, y, width, height, tocolor( 255, 0, 0, 255) , 1, "default-bold" ) end function open() opened = not opened if opened == true then addEventHandler("onClientRender", getRootElement(), drawName) else removeEventHandler("onClientRender", getRootElement(), drawName) end end bindKey("F11","down",open) Link to comment
MoeezKhan Posted January 29, 2014 Author Share Posted January 29, 2014 not working local screenW, screenH = guiGetScreenSize() function drawName() dxDrawText("Criminal", x="2035.3903808594", y="1349.2917480469", width="3", height="2", tocolor( 255, 0, 0, 255) , 1, "default-bold" ) end function open() opened = not opened if opened == true then addEventHandler("onClientRender", getRootElement(), drawName) else removeEventHandler("onClientRender", getRootElement(), drawName) end end bindKey("F11","down",open) Link to comment
Karuzo Posted January 29, 2014 Share Posted January 29, 2014 You really know something about scripting? Link to comment
MoeezKhan Posted January 29, 2014 Author Share Posted January 29, 2014 yes i khow only simple thing because i am new in lua Link to comment
Mefisto_PL Posted January 29, 2014 Share Posted January 29, 2014 You've got simple example in wiki.. Read comments to this function on wiki and make it with syntax. Link to comment
ViRuZGamiing Posted January 29, 2014 Share Posted January 29, 2014 Write: local x, y, width, height= 2035.3903808594, 1349.2917480469, 3, 2 -- Not quite sure if this is right dxDrawText("Criminal", x, y, width, height, tocolor( 255, 0, 0, 255) , 1, "default-bold" ) OR fill in the argument (I prefer this) dxDrawText("Criminal", 2035.3903808594,1349.2917480469, 3, 2, tocolor( 255, 0, 0, 255) , 1, "default-bold" ) Link to comment
Moderators IIYAMA Posted January 29, 2014 Moderators Share Posted January 29, 2014 You forgot to convert world position to screenposition. https://wiki.multitheftauto.com/wiki/Ge ... ldPosition Link to comment
ViRuZGamiing Posted January 29, 2014 Share Posted January 29, 2014 You forgot to convert world position to screenposition. https://wiki.multitheftauto.com/wiki/Ge ... ldPosition Yea didn't know he wanted the World Position thats why it sounded so weird Link to comment
Dealman Posted January 29, 2014 Share Posted January 29, 2014 Of course it's not working when the function wants X, Y, Width and Height to be a float value, but you're making it a string. I suggest you look up some basic LUA tutorials to learn the difference between Integer, Float and Strings. Things you did wrong; • Named your function the same as the dxDrawText. They will conflict with eachother. • You tried to make a variable called "createdxDrawText" containing multiple arguments. • You provided the X, Y and Z coordinates as a string, it needs to be a float value. No Z value needed. (Keep in mind that providing ingame X, Y and Z coordinates will not make it look like it's being displayed inside the world itself.) • You made a typo, addEventHandler • 3rd argument in bindKey has to be the function it's attached to, you gave it a string. • Tried to use onResourceStart which is server-side. Doesn't work client-side. Use onClientResourceStart. • You used getRootElement() instead of resourceRoot, meaning the code will trigger everytime ANY resource is started. resourceRoot means it will only trigger when that specific resource is started. • You never used onClientRender or onClientPreRender, text would only draw for 1 frame. • You never closed the function with end. • Some more errors... Example of fixed code; local screenWidth, screenHeight = guiGetScreenSize() local isBeingDrawn = false function startDrawingOnStart_Handler() if(isBeingDrawn == false) then -- Make an if statement to change the variable when the function is triggered. addEventHandler("onClientPreRender", root, textToDraw_Handler) -- Add the Event Handler to draw the text for each frame. isBeingDrawn = true else removeEventHandler("onClientPreRender", root, textToDraw_Handler) -- Remove the Event Handler. isBeingDrawn = false end -- Close the if statement. end --addEventHandler("onClientResourceStart", resourceRoot, startDrawingOnStart_Handler) Uncomment this if you want it to draw as the resource is started. bindKey("F11", "down", startDrawingOnStart_Handler) function textToDraw_Handler() dxDrawText("Some text here", 392, 251, 954, 319, tocolor(0, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) -- Text Shadow dxDrawText("Some text here", 391, 250, 953, 318, tocolor(127, 0, 0, 255), 1.00, "bankgothic", "center", "center", false, false, true, false, false) -- Text Coloured end Link to comment
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