[Release] Time And Date Display v0.4

Okey but it gives me gametime not irl time.

Yeah I know, you asked for 24 hours, not irl time. The functions for the time, hour and minute and retrieving in game time, not irl time. Just change the functions.

Okey the 24 hour did work fine. ty for that. But where to change or add so the time gets irl time?

I can’t remember how I did it on mine sorry, make a request in #development:scripts

okey, you can just look on your script.

No, because mine is completely different.

okey then i have to google it :stuck_out_tongue:

Sorry mate.

(20 Chars)

Hey man since people were messaging me to release mine, I customized yours to add an fps counter. Do you mind if I release it as a customized version? @Kymac

3 Likes

Anyone know how I can change the anchor from the top right to the top left?

Replace draw text information with

SetTextFont(0)
		SetTextProportional(1)
		SetTextScale(0.30, 0.30)
		SetTextColour(255, 255, 255, 255)
		SetTextDropshadow(0, 0, 0, 0, 255)
		SetTextEdge(1, 0, 0, 0, 255)
		SetTextDropShadow()
		SetTextOutline()
		SetTextRightJustify(true)
		SetTextWrap(0.1,0.28)
		SetTextEntry("STRING")
		
		AddTextComponentString(timeAndDateString)
		DrawText(0.01, 0.01)
		
	end
end)

Edit the 0.28 on SetTextWrap to move it.

1 Like

:pray: Thanks, you’re a life saver!

1 Like

is there a way to sync the GTA time with this

It is? It’s only displaying the current ingame time. I’m using this with vSync (which sync’s your server time to GTA:O time by default)

1 Like

What are you talking about, it uses in game time, my one, uses real date and time, might add it to a customized version of this.

Nice little script my friend. +1 LIKED

can you add FPS to that

Yes I have already done this, would just need the owners permission to release it.

1 Like

I would say go for it, the creator of this script has not seen online since the start of February. Plus there’s no licence or anything of that nature on his git.

hmmm… yeah.

Why not, can always remove it if requested.

local displayTime = true
local useMilitaryTime = true
local displayDayOfWeek = true
local displayDate = true
local displayFps = true

local timeAndDateString = nil
local hour
local minute
local dayOfWeek
local month
local dayOfMonth
local year

local rgb = {r = 255, g = 153, b = 102}
local prevtime = GetGameTimer()
local prevframes = GetFrameCount()
local fps = -1

Citizen.CreateThread(function()
	while true do
		Wait(1)
		timeAndDateString = "~r~Time:"
		
		if displayTime == true then
			CalculateTimeToDisplay()
			timeAndDateString = timeAndDateString .. " ~w~" .. hour .. "~r~:~w~" .. minute .. "~r~ | "
		end
		if displayDayOfWeek == true then
			CalculateDayOfWeekToDisplay()
			timeAndDateString = timeAndDateString .. "~w~" .. dayOfWeek .. "~r~ | "
		end
		if displayDate == true then
			CalculateDateToDisplay()
			timeAndDateString = timeAndDateString .. "~w~" .. month .. "~r~/~w~" .. dayOfMonth .. "~r~/~w~" .. year .. "~r~ | ~w~"
		end
		if displayFps == true then
			CalculateDateToDisplay()
			timeAndDateString = timeAndDateString .. "~w~" .. fps .. " ~r~FPS ~r~"
		end

		SetTextFont(0)
		SetTextProportional(1)
		SetTextScale(0.30, 0.30)
		SetTextColour(255, 255, 255, 255)
		SetTextDropshadow(0, 0, 0, 0, 255)
		SetTextEdge(1, 0, 0, 0, 255)
		SetTextDropShadow()
		SetTextOutline()
		SetTextRightJustify(true)
		SetTextWrap(0.1,0.93)
		SetTextEntry("STRING")
		
		AddTextComponentString(timeAndDateString)
		DrawText(0.01, 0.01)
		
	end
end)

function CalculateTimeToDisplay()
	hour = GetClockHours()
	minute = GetClockMinutes()

	if useMilitaryTime == false then
		if hour == 0 or hour == 24 then
			hour = 12
		elseif hour >= 13 then
			hour = hour - 12
		end
	end

	if hour <= 9 then
		hour = "0" .. hour
	end
	if minute <= 9 then
		minute = "0" .. minute
	end
end

function CalculateDayOfWeekToDisplay()
	dayOfWeek = GetClockDayOfWeek()
	
	if dayOfWeek == 0 then
		dayOfWeek = "Sunday"
	elseif dayOfWeek == 1 then
		dayOfWeek = "Monday"
	elseif dayOfWeek == 2 then
		dayOfWeek = "Tuesday"
	elseif dayOfWeek == 3 then
		dayOfWeek = "Wednesday"
	elseif dayOfWeek == 4 then
		dayOfWeek = "Thursday"
	elseif dayOfWeek == 5 then
		dayOfWeek = "Friday"
	elseif dayOfWeek == 6 then
		dayOfWeek = "Saturday"
	end
end

function CalculateDateToDisplay()
	month = GetClockMonth()
	dayOfMonth = GetClockDayOfMonth()
	year = 2018
	
	if month == 0 then
		month = "1"
	elseif month == 1 then
		month = "2"
	elseif month == 2 then
		month = "3"
	elseif month == 3 then
		month = "4"
	elseif month == 4 then
		month = "5"
	elseif month == 5 then
		month = "6"
	elseif month == 6 then
		month = "7"
	elseif month == 7 then
		month = "8"
	elseif month == 8 then
		month = "9"
	elseif month == 9 then
		month = "10"
	elseif month == 10 then
		month = "11"
	elseif month == 11 then
		month = "12"
	end
end

Citizen.CreateThread(function()	  
        
        while not NetworkIsPlayerActive(PlayerId()) or not NetworkIsSessionStarted() do	        
            Citizen.Wait(250)
            prevframes = GetFrameCount()
            prevtime = GetGameTimer()            
	end

        while true do		 
            curtime = GetGameTimer()
	        curframes = GetFrameCount()	   
		
	    if((curtime - prevtime) > 1000) then
		    fps = (curframes - prevframes) - 1				
		    prevtime = curtime
		    prevframes = curframes
	    end

            if IsGameplayCamRendering() and fps >= 0 then
	            PrintText(fps .. " FPS")
            end            
            Citizen.Wait(1)		
       end	
end)

function PrintText(text)
	SetTextEntry("STRING")
end