Ingame time data?

is there a way to get the time data from the game or server? :slight_smile: not irl time but the clock ingame?

Yup, you can!

local hour = GetClockHours()
local minute = GetClockMinutes()

There are several more natives regarding time & date. You can find some of them if you search for “clock” in the fivem native reference.

https://runtime.fivem.net/doc/reference.html

Hope this helped! :wink:

So if i have to display the clock on the HUD ingame, how to do then? :slight_smile:

Citizen.CreateThread(function()
	while true do
		Wait(0)
		local t = {h = GetClockHours(), m = GetClockMinutes(), s = GetClockSeconds()}
		drawTxt(string.format("%02d:%02d:%02d", t.h, t.m, t.s), 0.01, 0.1, 0.5, 255, 255, 255, 255, 1)
	end
end)

function drawTxt(text, x, y, scale, r, g, b, a, outline)
	SetTextFont(0)
	SetTextProportional(0)
	SetTextScale(scale, scale)
	SetTextColour(r, g, b, a)
	SetTextDropShadow(0, 0, 0, 0,255)
	SetTextEdge(1, 0, 0, 0, 255)
	SetTextDropShadow()
	if(outline)then
		SetTextOutline()
	end
	SetTextEntry("STRING")
	AddTextComponentString(text)
	DrawText(x, y)
end