font.render: Difference between revisions

979 bytes added ,  24 September 2021
Fixed the params section; added an example
No edit summary
(Fixed the params section; added an example)
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);
}
}
});
}}
}}
7

edits