diff --git a/HUD/BeginTextCommandDisplayText.md b/HUD/BeginTextCommandDisplayText.md index f2f0fda82..4a0a162b4 100644 --- a/HUD/BeginTextCommandDisplayText.md +++ b/HUD/BeginTextCommandDisplayText.md @@ -9,14 +9,33 @@ aliases: ["_SET_TEXT_ENTRY"] void BEGIN_TEXT_COMMAND_DISPLAY_TEXT(char* text); ``` -``` -The following were found in the decompiled script files: -STRING, TWOSTRINGS, NUMBER, PERCENTAGE, FO_TWO_NUM, ESMINDOLLA, ESDOLLA, MTPHPER_XPNO, AHD_DIST, CMOD_STAT_0, CMOD_STAT_1, CMOD_STAT_2, CMOD_STAT_3, DFLT_MNU_OPT, F3A_TRAFDEST, ES_HELP_SOC3 -ESDOLLA -ESMINDOLLA - cash (negative) -Used to be known as _SET_TEXT_ENTRY -``` +Begin a new Text Command. +Add the needed components with [ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME](#_0x6C188BE134E074AA) (and other ADD_TEXT_COMPONENT natives) +The Text components here refer to placeholders, see [content-formatting-codes](https://docs.fivem.net/docs/game-references/text-formatting/#content-formatting-codes) + +To add a custom text entry see [ADD_TEXT_ENTRY](#_0x32CA01C3) + +For some example label names see [_GET_LABEL_TEXT](#_0x7B5280EBA9840C72). ## Parameters -* **text**: +* **text**: The gxtEntry to use + +## Examples + +```lua +-- Display text with Text Entry +AddTextEntry("HELLO_WORLD", "Hello World") + +SetTextFont(0) +SetTextScale(0.0, 0.30) +BeginTextCommandDisplayText("HELLO_WORLD") +EndTextCommandDisplayText(0.3, 0.3) + +-- Display text with substring +SetTextFont(0) +SetTextScale(0.0, 0.30) +BeginTextCommandDisplayText("STRING") +AddTextComponentSubstringPlayerName("Hello World") +EndTextCommandDisplayText(0.3, 0.3) +``` diff --git a/HUD/GetLabelText.md b/HUD/GetLabelText.md index 05f997ad7..a27248abf 100644 --- a/HUD/GetLabelText.md +++ b/HUD/GetLabelText.md @@ -8,12 +8,65 @@ ns: HUD char* _GET_LABEL_TEXT(char* labelName); ``` -``` Gets a string literal from a label name. -GET_F* -``` + +Most useful application for this is getting vehicle labels from result of [GET_DISPLAY_NAME_FROM_VEHICLE_MODEL](#_0xB215AAC32D25D019) + +For a full list of built-in labels search for **global.gxt2** in GTA Files. + +To add a custom text entry see [ADD_TEXT_ENTRY](#_0x32CA01C3) + +Some example label names are: + +STRING, TWOSTRINGS, NUMBER, PERCENTAGE, FO_TWO_NUM, ESMINDOLLA, ESDOLLA, MTPHPER_XPNO, AHD_DIST, CMOD_STAT_0, CMOD_STAT_1, CMOD_STAT_2, CMOD_STAT_3, DFLT_MNU_OPT, F3A_TRAFDEST, ES_HELP_SOC3 ## Parameters -* **labelName**: +* **labelName**: The label name to get the text/label from ## Return value + +The label text, or "NULL" (not nil, but string literal NULL) if not found + +## Examples + +```lua +local label = GetLabelText("STRING") + +print(label) -- ~a~ + +local label = GetLabelText("ESDOLLA") + +print(label) -- $~a~ + +local label = GetLabelText("ESMINDOLLA") + +print(label) -- -$~a~ + +local label = GetLabelText("DFLT_MNU_OPT") + +print(label) -- Exit + +-- Non existent label +local label = GetLabelText("this_label_doesnt_exist") + +print(label) -- NULL + +local model = `baller` +local displayName = GetDisplayNameFromVehicleModel(model) +local vehicleLabel = GetLabelText(displayName) + +if vehicleLabel == "NULL" then + print(vehicleLabel) -- Baller +else + -- Label not found, use displayName instead + print(displayName) -- BALLER + vehicleLabel = displayName +end + +local makeName = GetMakeNameFromVehicleModel(model) +local makeLabel = GetLabelText(makeName) +if makeLabel ~= "NULL" then + print(("%s %s"):format(makeLabel, vehicleLabel)) -- Gallivanter Baller +end + +``` \ No newline at end of file