Ui::getTextSubstringSafe: Difference between revisions

From RAGE Multiplayer Wiki
(yay)
 
No edit summary
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Returns a substring of a specified length starting at a specified position. The result is guaranteed not to exceed the specified max length.<br><br>NOTE: The 'maxLength' parameter might actually be the size of the buffer that is returned. More research is needed. -CL69<br><br>Example:<br>// Condensed example of how Rockstar uses this function<br>strLen = UI::GET_LENGTH_OF_LITERAL_STRING(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT());<br>subStr = UI::_GET_TEXT_SUBSTRING_SAFE(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT(), 0, strLen, 63);<br><br>--<br><br>'fm_race_creator.ysc', line 85115:<br>// parameters modified for clarity<br>BOOL sub_8e5aa(char *text, int length) {<br>    for (i = 0; i &lt;= (length - 2); i += 1) {<br>        if (!GAMEPLAY::ARE_STRINGS_EQUAL(UI::_GET_TEXT_SUBSTRING_SAFE(text, i, i + 1, 1), ' ')) {<br>            return FALSE;<br>        }<br>    }<br>    return TRUE;<br>}
Returns a substring of a specified length starting at a specified position. The result is guaranteed not to exceed the specified max length.<br><br>NOTE: The 'maxLength' parameter might actually be the size of the buffer that is returned. More research is needed. -CL69<br><br>Example:<br>// Condensed example of how Rockstar uses this function<br>strLen = UI::GET_LENGTH_OF_LITERAL_STRING(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT());<br>subStr = UI::_GET_TEXT_SUBSTRING_SAFE(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT(), 0, strLen, 63);<br><br>--<br><br>'fm_race_creator.ysc', line 85115:<br>// parameters modified for clarity<br>BOOL sub_8e5aa(char *text, int length) {<br>    for (i = 0; i &lt;= (length - 2); i += 1) {<br>        if (!GAMEPLAY::ARE_STRINGS_EQUAL(UI::_GET_TEXT_SUBSTRING_SAFE(text, i, i + 1, 1), ' ')) {<br>            return FALSE;<br>        }<br>    }<br>    return TRUE;<br>}
==Syntax==
==Syntax==
<syntaxhighlight lang="javascript">ui.getTextSubstringSafe(text, position, length, maxLength);</syntaxhighlight>
<syntaxhighlight lang="javascript">mp.game.ui.getTextSubstringSafe(text, position, length, maxLength);</syntaxhighlight>
=== Required Arguments ===
=== Required Arguments ===
*'''text:''' String
*'''text:''' String
Line 11: Line 11:
==Example==
==Example==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
todo
// todo
</syntaxhighlight>
</syntaxhighlight>
==See also==
==See also==
{{Ui_function_c}}
{{Ui_s_function_c}}
[[Category:Clientside API]]
[[Category:Clientside API]]
[[Category:UI API]]
[[Category:TODO: Example]]
[[Category:TODO: Example]]

Latest revision as of 14:57, 20 May 2017

Returns a substring of a specified length starting at a specified position. The result is guaranteed not to exceed the specified max length.

NOTE: The 'maxLength' parameter might actually be the size of the buffer that is returned. More research is needed. -CL69

Example:
// Condensed example of how Rockstar uses this function
strLen = UI::GET_LENGTH_OF_LITERAL_STRING(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT());
subStr = UI::_GET_TEXT_SUBSTRING_SAFE(GAMEPLAY::GET_ONSCREEN_KEYBOARD_RESULT(), 0, strLen, 63);

--

'fm_race_creator.ysc', line 85115:
// parameters modified for clarity
BOOL sub_8e5aa(char *text, int length) {
for (i = 0; i <= (length - 2); i += 1) {
if (!GAMEPLAY::ARE_STRINGS_EQUAL(UI::_GET_TEXT_SUBSTRING_SAFE(text, i, i + 1, 1), ' ')) {
return FALSE;
}
}
return TRUE;
}

Syntax

mp.game.ui.getTextSubstringSafe(text, position, length, maxLength);

Required Arguments

  • text: String
  • position: int
  • length: int
  • maxLength: int

Return value

  • String

Example

// todo

See also