M MY Multiplayer: Wiki
Side
Kind

dxDrawText

Client

Draws text on the screen for one frame, inside a box.

bool dxDrawText(string text, float leftX, topY [, float rightX, bottomY = leftX, topY, color color = tocolor(255, 255, 255), float scaleX, scaleY = 1, string|element font = default, string alignX = left, string alignY = top, bool clip = false, bool wordBreak = false, bool postGUI = false, bool colorCoded = false, bool subPixelPositioning = false, float rotation = 0, float rotationCenterX, rotationCenterY = nil, float lineHeight = 0])

Parameters

NameTypeDescription
textstringThe text, in UTF-8. \n breaks the line.
leftX, topYfloatTop-left corner of the box, in pixels. A vec2 also works.
rightX, bottomYfloatBottom-right corner of the box, in pixels. A vec2 also works.default leftX, topY
colorcolorColour, a tocolor value.default tocolor(255, 255, 255)
scaleX, scaleYfloatText scale. One number applies to both axes. A vec2 also works.default 1
fontstring|elementA font's name (from a pack or given to dxCreateFont) or a font element from dxCreateFont.default default
alignXstringHorizontal alignment in the box: left, center or right.default left
alignYstringVertical alignment in the box: top, center or bottom.default top
clipboolCut what falls outside the box.default false
wordBreakboolWrap lines that do not fit the box's width.default false
postGUIboolDraw on top of the interface.default false
colorCodedboolRead #RRGGBB colour codes inside the text.default false
subPixelPositioningboolKeep fractional positions instead of snapping to whole pixels.default false
rotationfloatRotation in degrees.default 0
rotationCenterX, rotationCenterYfloatCentre of the rotation, in pixels. The box's centre by default.default nil
lineHeightfloatHeight of each line in pixels. 0 uses the font's height.default 0

Returns

true once the drawing is queued, false when the font does not exist.

Example

local sx, sy = getScreenSize()

addEventHandler("onClientRender", root, function()
    dxDrawText("#FFAA00MYMP #FFFFFFRoleplay", 0, 20, sx, 60, tocolor(255, 255, 255), 2, "default", "center", "top", false, false, false, true)
end)
NotelineHeight only applies to colorCoded text; text without colour codes always uses the font's height. A font name that does not exist logs a warning and the function returns false.

See also