natives.setTextCentre
Jump to navigation
Jump to search
Function Client Only ![]()
Online and Offline
Available since Client 1.0.0
void natives.setTextCentre(bool centre)
The natives.setTextCentre function is used to Sets whether text drawn on the screen should be horizontally centered.
Parameters
| 1) | bool | centre | True to center the text horizontally, false to align normally (left by default). |
Return
| void | This function doesn't return a value. |
Notes
- - Must be called before natives.displayTextWithLiteralString or similar text drawing functions- Only affects horizontal alignment; vertical alignment is controlled separately- Useful for HUD elements or messages that need to be centered on screen.
Examples
Example 1 - JavaScript:
addEventHandler("OnDrawnHUD", function() {
// Centered text example natives.setTextScale(0.30, 0.30); natives.setTextFont(0); natives.setTextColour(255, 255, 255, 255); natives.setTextCentre(true);
natives.displayTextWithLiteralString(new Vec2(0.50, 0.10), "STRING", "Text centered on screen");
});
Compatibility
There isn't any compatibility information for this function.