Skip to content

Commit

Permalink
Add example labels to _GET_LABEL_TEXT, and refer to _GET_LABEL_TEXT f…
Browse files Browse the repository at this point in the history
…rom ADD_TEXT_COMPONENT_SUBSTRING_PLAYER_NAME
  • Loading branch information
niekschoemaker committed Oct 13, 2023
1 parent 1569d8c commit 5ccfbdb
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
2 changes: 2 additions & 0 deletions HUD/AddTextComponentSubstringPlayerName.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Adds an arbitrary string as a text component placeholder, replacing `~a~` in the
See the documentation on text formatting for more information.
For some example label names see [_GET_LABEL_TEXT](?_0x7B5280EBA9840C72).
## Parameters
* **text**: A string to add of up to 99 characters. This can contain additional `~` formatting directives.
Expand Down
61 changes: 57 additions & 4 deletions HUD/GetLabelText.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit 5ccfbdb

Please sign in to comment.