xXMADEXx Posted April 4, 2013 Posted April 4, 2013 Im trying to make a dx text message thing in the center of the screen, but im not sure how to get the colors/text to transfer over: function dxDrawCenteredText(newText,r,g,b) newText = newText or "Failed" r = tonumber(r) or 255 g = tonumber(g) or 0 b = tonumber(b) or 0 if not(isTimer(newDxTimer)) then addEventHandler("onClientRender",root,startCentredText) newDxTimer = setTimer( function () removeEventHandler("onClientRender",root,startCentredText) end, 5000, 1 ) end end addEvent("message:centerText",true) addEventHandler("message:centerText",root,dxDrawCenteredText) function startCentredText() local rx, ry = guiGetScreenSize() dxDrawBorderedText(newText,0, 0, rx, ry, tocolor(r,g,b,255), 5, "sans", "center", "center", false, false, true) end function dxDrawBorderedText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) local wh = 4 dxDrawText ( text, x - wh, y - wh, w - wh, h - wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black dxDrawText ( text, x + wh, y - wh, w + wh, h - wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - wh, y + wh, w - wh, h + wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + wh, y + wh, w + wh, h + wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - wh, y, w - wh, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + wh, y, w + wh, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - wh, w, h - wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + wh, w, h + wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end addCommandHandler("test2", function () dxDrawCenteredText("Testing", 255, 255, 0) end )
Castillo Posted April 4, 2013 Posted April 4, 2013 local newText = "" local r, g, b = 255, 0, 0 function dxDrawCenteredText ( text, r, g, b ) newText = text or "Failed" r = tonumber ( r ) or 255 g = tonumber ( g ) or 0 b = tonumber ( b ) or 0 if ( not isTimer ( newDxTimer ) ) then addEventHandler ( "onClientRender", root, startCentredText ) newDxTimer = setTimer ( function ( ) removeEventHandler ( "onClientRender", root, startCentredText ) end, 5000, 1 ) end end addEvent ( "message:centerText", true ) addEventHandler ( "message:centerText", root, dxDrawCenteredText ) function startCentredText ( ) local rx, ry = guiGetScreenSize ( ) dxDrawBorderedText ( newText, 0, 0, rx, ry, tocolor ( r, g, b, 255 ), 5, "sans", "center", "center", false, false, true ) end addCommandHandler ( "test2", function ( ) dxDrawCenteredText ( "Testing", 255, 255, 0 ) end ) function dxDrawBorderedText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) local wh = 4 dxDrawText ( text, x - wh, y - wh, w - wh, h - wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) -- black dxDrawText ( text, x + wh, y - wh, w + wh, h - wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - wh, y + wh, w - wh, h + wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + wh, y + wh, w + wh, h + wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x - wh, y, w - wh, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x + wh, y, w + wh, h, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y - wh, w, h - wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y + wh, w, h + wh, tocolor ( 0, 0, 0, 255 ), scale, font, alignX, alignY, clip, wordBreak, false ) dxDrawText ( text, x, y, w, h, color, scale, font, alignX, alignY, clip, wordBreak, postGUI ) end Try it.
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