font.render: Difference between revisions

From GTA Connected
Jump to navigation Jump to search
(Fixed the params section; added an example)
m (fixed the script example's spacing)
 
Line 43: Line 43:
return;
return;


if(sdl.ticks - gameMsgStart < gameMsgDuration ) {
if (sdl.ticks - gameMsgStart < gameMsgDuration ) {
if(gameMsgFont != null) {
if (gameMsgFont != null) {
gameMsgFont.render(gameMsgText, [0, gta.height-45], gta.width, 0.5, 0.0, gameMsgFont.size, gameMsgColour, true, true, false, true);
gameMsgFont.render(gameMsgText, [0, gta.height - 45], gta.width, 0.5, 0.0, gameMsgFont.size, gameMsgColour, true, true, false, true);
}
}
}
}
});
});
}}
}}

Latest revision as of 15:21, 3 October 2021

Method Client Only icon-iii.png icon-vc.png icon-sa.png icon-iv.png Online and Offline

Available since Client 1.0.0

void font.render(string text, Vec2 position, float width, float align, float justify, float size, int colour, [ bool wordWrap = false, bool colourCodes = true, bool ignoreColourCodes = false, bool shadow = false ])

The font.render method is used to draw text on the screen using a font.

Parameters

1) string text The text to draw.
2) Vec2 position The 2D position for the text.
3) float width The maximum width of the text, in pixels.
4) float align The horizontal alignment of the text, as a float.
5) float justify The justify alignment of the text, as a float.
6) float size The size of the text, as a float.
7) int colour The colour of the text, as an integer; visit the colour defines page for info.
8) bool wordWrap Optional, defaults to false. Whether word wrap is enabled.
9) bool colourCodes Optional, defaults to true. Whether colour codes are resolved.
10) bool ignoreColourCodes Optional, defaults to false. Whether colour codes are not resolved.
11) bool shadow Optional, defaults to false. Whether to draw a shadow for the text.

Return

void This method doesn't return a value.

Types

Client Font

Notes

Examples

Example 1 - JavaScript - Client-Side:

let gameMsgFont = null; let gameMsgText = "Welcome to the server."; let gameMsgColour = COLOUR_YELLOW; let gameMsgDuration = 7500; let gameMsgStart = 0;

bindEventHandler("OnResourceReady", thisResource, (event, resource) => {

   let fontStream = openFile("pricedown.ttf");
   if (fontStream != null) {
       gameMsgFont = lucasFont.createFont(fontStream, 28.0);
       fontStream.close();
   }

});

bindEventHandler("OnResourceStart", thisResource, (event, resource) => {

   gameMsgStart = sdl.ticks;

});

addEventHandler("OnDrawnHUD", (event) => { if (gta.ivGamemode != 8) return;

if (sdl.ticks - gameMsgStart < gameMsgDuration ) { if (gameMsgFont != null) { gameMsgFont.render(gameMsgText, [0, gta.height - 45], gta.width, 0.5, 0.0, gameMsgFont.size, gameMsgColour, true, true, false, true); } } });

Compatibility

There isn't any compatibility information for this method.

Related

Client Related

icon-iii.png icon-vc.png icon-sa.png icon-iv.png font.measure
icon-iii.png icon-vc.png icon-sa.png icon-iv.png font.render
icon-iii.png icon-vc.png icon-sa.png icon-iv.png font.size