Skip to content

Instantly share code, notes, and snippets.

@MrGrootx
Last active February 23, 2024 11:51
Show Gist options
  • Select an option

  • Save MrGrootx/c73c1d12b207d9347c565fbe054580a7 to your computer and use it in GitHub Desktop.

Select an option

Save MrGrootx/c73c1d12b207d9347c565fbe054580a7 to your computer and use it in GitHub Desktop.
fivem show timer as text
local remainingsec = 0
function disp_time(time)
local minutes = math.floor((time % 3600 / 60))
local seconds = math.floor((time % 60))
return string.format("%02dm %02ds", minutes, seconds)
end
-- startTimer()
function startTimer()
Citizen.CreateThread(function()
Citizen.CreateThread(function()
while remainingsec > 0 do
remainingsec = remainingsec - 1
Citizen.Wait(1000)
end
end)
while remainingsec > 0 do
Citizen.Wait(0)
SetTextFont(4)
SetTextScale(0.45, 0.45)
SetTextColour(185, 185, 185, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
BeginTextCommandDisplayText('STRING')
AddTextComponentSubstringPlayerName(disp_time(remainingsec) .. " - Time Remaining")
EndTextCommandDisplayText(0.05, 0.55)
end
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment