[HELP] Increase the duration of a help message

Hey, so I want to make a message appear for the player but at the minute it appears for like half a second.

When they reach an area a message appears telling them to press E to search:
Screenshot 2023-12-12 143405

If they are inside a vehicle and they press E to search I want a message to appear for a certain amount of time that states that they must exit the vehicle to search. My current code does this but the message appears and then dissapears in a flash.

This is my function for creating a message:

local function ShowNotification(text)
  SetTextComponentFormat("STRING")
  AddTextComponentString(text)
  DisplayHelpTextFromStringLabel(0, 0, 1, 50)
end

I have tried messing around with the last parameter of the DisplayHelpTextFromStringLabel but nothing changed.

Here is my code for checking the distance and when to display the mesages:

local function CheckDistance(loc)
  CreateThread(function()
    while true do

      local playerCoords = GetEntityCoords(playerId)
      local distance = #(playerCoords - loc.coords)

      if distance < 8.0 then
        DisplayMarker()

        if distance < 2.0 then
          ShowNotification('Press ~INPUT_PICKUP~ to Search')
          
          if IsControlJustPressed(0, 38) then
            if not IsPedInAnyVehicle(playerId, true) then
              print('You searched for treasure and found nothing!')
              isHuntActive = false
              break
            else
              ShowNotification('You must exit the vehicle to search!')
            end
          end
        end
      end
      Wait(0)
    end
  end)
end

Any help would be appreciated, thanks!

The fourth parameter is the duration in ms of how long this message should display for.

local function ShowNotification(text)
     BeginTextCommandDisplayHelp("STRING")
     AddTextComponentSubstringPlayerName(text)
     EndTextCommandDisplayHelp(0, false, true, 5000) -- displays for 5s
end
1 Like

Thank you, I will try this out!

Hey, so I’m still having the issue where the message displays for a split second.

This is the code I put into the function:

local function ShowNotification(text)
  BeginTextCommandDisplayHelp("STRING")
  AddTextComponentSubstringPlayerName(text)
  EndTextCommandDisplayHelp(0, false, true, 3000)
end

I am now starting to think maybe I am looping back over and not giving the message a chance to display for the duration set. The problem is I’m a beginner and I’m not sure where I am going wrong.

Here is my code, do you see any areas that are causing this issue?

local function CheckDistance(loc)
  CreateThread(function()
    while true do

      local playerCoords = GetEntityCoords(playerId)
      local distance = #(playerCoords - loc.coords)

      if distance < 8.0 then
        DisplayMarker()

        if distance < 2.0 then
          ShowNotification('Press ~INPUT_PICKUP~ to Search')
          
          if IsControlJustPressed(0, 38) then
            if not IsPedInAnyVehicle(playerId, true) then
              print('You searched for treasure and found nothing!')
              isHuntActive = false
              break
            else
              ShowNotification('You must exit the vehicle to search!')
            end
          end
        end
      end
      Wait(0)
    end
  end)
end

Thanks for your help!

UPDATE: Adding Wait(3000) after calling the function works but the parameter does not:

local function CheckDistance(loc)
  CreateThread(function()
    while true do

      local playerCoords = GetEntityCoords(playerId)
      local distance = #(playerCoords - loc.coords)

      if distance < 8.0 then
        DisplayMarker()

        if distance < 2.0 then
          ShowNotification('Press ~INPUT_PICKUP~ to Search')
          
          if IsControlJustPressed(0, 38) then
            if not IsPedInAnyVehicle(playerId, true) then
              print('You searched for treasure and found nothing!')
              isHuntActive = false
              break
            else
              ShowNotification('You must exit the vehicle to search!')
              Wait(3000)
            end
          end
        end
      end
      Wait(0)
    end
  end)
end