Common ways to display help text

Noticed some confusion about ways to display help text and why you’d want to use one way over another, so here’s some snippet that I’d use to display help text.

Option 1 (looped)

CreateThread(function()
    while true do
        Wait(0)
        -- if statement here
        BeginTextCommandDisplayHelp("THREESTRINGS")
        AddTextComponentSubstringPlayerName("line one")
        AddTextComponentSubstringPlayerName("line two")
        AddTextComponentSubstringPlayerName("line three")
        
        -- shape (always 0), loop (bool), makeSound (bool), duration (0 for loop)
        EndTextCommandDisplayHelp(0, true, false, 0)
    end
end)

Option 2 (non-looped)

function message(lineOne, lineTwo, lineThree, duration)
    BeginTextCommandDisplayHelp("THREESTRINGS")
    AddTextComponentSubstringPlayerName(lineOne)
    AddTextComponentSubstringPlayerName(lineTwo or "")
    AddTextComponentSubstringPlayerName(lineThree or "")

    -- shape (always 0), loop (bool), makeSound (bool), duration (5000 max 5 sec)
    EndTextCommandDisplayHelp(0, false, true, duration or 5000)
end

Option 3 (looped, but with labels or a custom text string using AddTextEntry, detailed info about labels can be found here, existing labels dump here)

CreateThread(function()
    -- only call this once!! (or skip this if you want to use an existing label)
    -- if you register this in some other script then you don't need to re-register this here.
    AddTextEntry("some_unique_name_never_used_anywhere_else", "The message you want to be displayed")
    
    while true do
        Wait(0)
        -- if statement here
        DisplayHelpTextThisFrame("some_unique_name_never_used_anywhere_else", false)
    end
end)
8 Likes

Awesome tutorial! Thanks.

When I use the 1. method, my HelpText just stays there, even after the if statement is not fulfilled. Any suggestions on why?

1 Like
local showHelpNotification = function(msg1 --[[ string ]], msg2 --[[ string ]], msg3 --[[ string ]])	
	BeginTextCommandDisplayHelp("THREESTRINGS")
	AddTextComponentSubstringPlayerName(msg1)
    AddTextComponentSubstringPlayerName(msg2 and "~n~"..msg2 or "")
    AddTextComponentSubstringPlayerName(msg3 and "~n~"..msg3 or "")
	EndTextCommandDisplayHelp(0, false, true, -1)
end

local function splitString(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

local help = "Hold ~INPUT_VEH_PUSHBIKE_PEDAL~ to cycle.\nHold ~INPUT_VEH_PUSHBIKE_SPRINT~ and tap ~INPUT_VEH_PUSHBIKE_PEDAL~ to cycle faster.\nPress ~INPUT_VEH_CAR_JUMP~ to Jump."
local text = splitString(help, "\n")
showHelpNotification(text[1], text[2], text[3])