Ui::getTextScreenWidth: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 8: Line 8:
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
// todo
const getTextWidth = (text, font, scale) => {
    mp.game.ui.setTextEntryForWidth("STRING");
    mp.game.ui.addTextComponentSubstringPlayerName(text);
    mp.game.ui.setTextFont(font);
    mp.game.ui.setTextScale(scale * 1.25, scale);
    return mp.game.ui.getTextScreenWidth(true);
};
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
Line 14: Line 20:
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:UI API]]
[[Category:UI API]]
[[Category:TODO: Example]]

Revision as of 21:36, 2 October 2018

In scripts font most of the time is passed as 1.
Use _SET_TEXT_ENTRY_FOR_WIDTH

param is not font from what i've tested

Syntax

mp.game.ui.getTextScreenWidth(p0);

Required Arguments

  • p0: Boolean

Return value

  • float

Example

const getTextWidth = (text, font, scale) => {
    mp.game.ui.setTextEntryForWidth("STRING");
    mp.game.ui.addTextComponentSubstringPlayerName(text);
    mp.game.ui.setTextFont(font);
    mp.game.ui.setTextScale(scale * 1.25, scale);
    return mp.game.ui.getTextScreenWidth(true);
};

See also