natives.setTextCentre: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
(Created page with "{{ScriptItem |endpoint = client |games = iv |type = function |name = natives.setTextCentre |parameters = bool centre |parameter1 = bool centre True to center the text horizontally, false to align normally (left by default) |usage = Sets whether text drawn on the screen should be horizontally centered |notes = - Must be called before natives.displayTextWithLiteralString or similar text drawing functions - Only affects horizontal alignment; vertical alignment is contr...")
 
(No difference)

Latest revision as of 16:50, 28 November 2025

Function Client Only icon-iv.png 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.