font.render: Difference between revisions

No edit summary
m (fixed the script example's spacing)
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
|parameter5 = float justify The justify alignment of the text, as a float.
|parameter5 = float justify The justify alignment of the text, as a float.
|parameter6 = float size The size of the text, as a float.
|parameter6 = float size The size of the text, as a float.
|parameter7 = bool wordWrap optional false Whether word wrap is enabled.
|parameter7 = int colour The colour of the text, as an integer; visit the [[Defines/IV#GTA_IV_-_Colour_Defines|colour defines]] page for info.
|parameter8 = bool colourCodes optional true Whether colour codes are resolved.
|parameter8 = bool wordWrap optional false Whether word wrap is enabled.
|parameter9 = bool ignoreColourCodes optional false Whether colour codes are not resolved.
|parameter9 = bool colourCodes optional true Whether colour codes are resolved.
|parameter10 = bool shadow optional false Whether to draw a shadow for the text.
|parameter10 = bool ignoreColourCodes optional false Whether colour codes are not resolved.
|parameter11 = bool shadow optional false Whether to draw a shadow for the text.
|usage = draw text on the screen using a font
|usage = draw text on the screen using a font
|return1 = void
|return1 = void
|returnFail1 = void
|returnFail1 = void
|notes = You can use different colours using [[Format_Tags]]
|notes = You can use different colours using [[Format_Tags]]
|exampleJSCS = 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);
}
}
});
}}
}}

Latest revision as of 15:21, 3 October 2021

render

Signature: void 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 ])

Usage: draw text on the screen using a font

Parameters

string text The text to draw.
Vec2 position The 2D position for the text.
float width The maximum width of the text, in pixels.
float align The horizontal alignment of the text, as a float.
float justify The justify alignment of the text, as a float.
float size The size of the text, as a float.
int colour The colour of the text, as an integer; visit the colour defines page for info.
bool wordWrap optional false Whether word wrap is enabled.
bool colourCodes optional true Whether colour codes are resolved.
bool ignoreColourCodes optional false Whether colour codes are not resolved.

Return

void

On failure: void