Last active
February 23, 2024 11:51
-
-
Save MrGrootx/c73c1d12b207d9347c565fbe054580a7 to your computer and use it in GitHub Desktop.
fivem show timer as text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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