[Release] Time And Date Display v0.4


#30

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


#32

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


#33

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.


#34

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


#35

is there a way to sync the GTA time with this


#36

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)


#37

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.


#38

Nice little script my friend. +1 LIKED


#39

can you add FPS to that


#40

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


#41

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.


#42

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


#43

I used yours, but its saying its Tuesday… lol…

Does it go by real time or in game?


#44

This isn’t mine, this is the fps edited one. Mine is from my old server, I would have to look for it.


#45

Oh alright…

Let me know if your gonna release it


#46

I would if I could find it :joy:


#47

Try to re-create it… lol…


#48

No thanks I am too busy, just use os.time


#49

I have the same problem. Did you find a solution in the meantime?


#50

I followed your example, but the only correct data that shows is the time, the number and the name of the day, the month and the year are completely wrong.