natives.displayTextWithLiteralString
Function Client Only ![]()
Online and Offline
Available since Client 1.0.0
void natives.displayTextWithLiteralString(Vec2 position, string literal, string text)
The natives.displayTextWithLiteralString function is used to Draws a text string on the screen at the specified position using a literal identifier.
Parameters
| 1) | Vec2 | position | Normalized screen coordinates (0.0–1.0) where the text will be drawn. |
| 2) | string | literal | Literal type for the text, usually "STRING". |
| 3) | string | text | The actual text content to display. |
Return
| void | This function doesn't return a value. |
Notes
- - Must be called inside a rendering event such as OnDrawnHUD so the text is drawn each frame- Use supporting natives like natives.setTextScale, natives.setTextColour, natives.setTextFont to style the text before calling- The literal is typically "STRING" for arbitrary text, but other literals may exist for predefined labels.
Examples
Example 1 - JavaScript:
addEventHandler("OnDrawnHUD", function() {
// Configure text style natives.setTextScale(0.40, 0.40); natives.setTextFont(0); natives.setTextColour(255, 255, 255, 255); natives.setTextCentre(false); natives.setTextProportional(true); natives.setTextDropshadow(true, 0, 0, 0, 255);
// Draw text at top-left corner natives.displayTextWithLiteralString(new Vec2(0.05, 0.10), "STRING", "Hi, text example");
});
Compatibility
There isn't any compatibility information for this function.