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.