[Release] Time And Date Display v0.4

can u share please on how to move it up and down?

today are December 12, 2018 more in my fivem indicates September 14, 2018, how to adjust to stay in accordance with the actual day?

Screenshot_1

1 Like

I was trying not to post anything on the FiveM forums about this as it is small but I have been trying to change the colour for a while. I’ll put my code below, If anyone could help I’d love that :slight_smile:

No matter what I put in the RGB section it is always red.

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 = 3, g = 184, b = 255}
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(3, 184, 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)

Seems like you are using my code simply remove ~r~ (~~) are used for colours.

Ohhh ok thank you a lot!

Also how would i reset the colour? For example I want the ‘|’ and the colon to be white but then the rest to be the blue colour I set in the RGB.

		if displayTime == true then
			CalculateTimeToDisplay()
			timeAndDateString = timeAndDateString .. " " .. hour .. "~w~:" .. minute .. "~w~ | "

Try

if displayTime == true then
			CalculateTimeToDisplay()
			timeAndDateString = timeAndDateString .. " ~b~" .. hour .. "~w~:~b~" .. minute .. "~w~ | "

For colours https://www.vespura.com/colors/

Hi, Im just wondering what this script is called.

I’m trying to clear up the screen for screenshots and I can’t find the script name. /stop **********

Thanks for your help!!

image
or what ever you named it

The server owner must have renamed it then. Thank you for your reply!

I need a script to show Players Date and time!

This should work.

Open for client.lua code.
function round(num, numDecimalPlaces)
  local mult = 10^(numDecimalPlaces or 0)
  return math.floor(num * mult + 0.5) / mult
end

function drawTxt4(x,y ,width,height,scale, text, r,g,b,a)
    SetTextFont(4)
    SetTextProportional(0)
    SetTextScale(scale, scale)
    SetTextColour(r, g, b, a)
    SetTextDropShadow(0, 0, 0, 0,255)
    SetTextEdge(2, 0, 0, 0, 255)
    SetTextDropShadow()
    SetTextOutline()
    SetTextEntry("STRING")
    AddTextComponentString(text)
    DrawText(x - width/2, y - height/2 + 0.005)
end

function GetTimeAndMinutes()

	gethour=GetClockHours()
	getmins=GetClockMinutes()

	local y,mo,d,h,m,s=GetLocalTime()

	minz=""
		if(getmins<=9)then
			minz="0"
		end

	local hour=h
		if(h>12)then
			hour=h-12
		end
		if(h==0)then
			hour="12"
		end

	local period="AM"
		if(h>=12)then
			period="PM"
		end

	local minutes=m
		if(m<10)then
			minutes="0"..m..""
		end


	if(DisplayTimeandDate)then
		drawTDMFPS(string.format("Time: ~w~%s:~w~%s%s~s~ | ~w~%s~s~/~w~%s~s~/~w~%s~s~ | AOP: ~w~"..CurrentAOP.. " " ..CurrentAOP2,gethour,minz,getmins,mo,d,y),1500,12.5,0.46,true,4,191,10,48,205)
	end
end
Citizen.CreateThread(function()
	while true do
		Wait(0)

		local ped_l=GetPlayerPed(-1)

		if(DoesEntityExist(ped_l))then
			GetTimeAndMinutes()
		end
	end
end)
function drawTDMFPS(text, x, y, size, center, font, r, g, b, a)
local resx,resy=GetScreenResolution() -- determines resoultion using native
	SetTextFont(font)
	SetTextScale(size,size)
	SetTextProportional(true)
	SetTextColour(Colors.r, Colors.g, Colors.b, Colors.a)
	SetTextCentre(center)
	SetTextDropshadow(0,0,0,0,0)
	SetTextOutline()
	SetTextEntry("STRING")
	AddTextComponentString(text)
	DrawText(HUD.Locationx - 0.425, HUD.Locationy - 0.471)
end

Not working… I need a script in the next format example: Online:1/32| 18 January 2019

Stealed from DGVANIX https://github.com/DGVaniX/vRP

for all who shows 2013 or 2018 and not reall time that should help u

local displayTime = true
local displayDate = true

local timeAndDateString = nil

function CalculateDayOfWeekToDisplay()
if dayOfWeek == 1 then
dayOfWeek = “Sunday”
elseif dayOfWeek == 2 then
dayOfWeek = “Monday”
elseif dayOfWeek == 3 then
dayOfWeek = “Tuesday”
elseif dayOfWeek == 4 then
dayOfWeek = “Wednesday”
elseif dayOfWeek == 5 then
dayOfWeek = “Thursday”
elseif dayOfWeek == 6 then
dayOfWeek = “Friday”
elseif dayOfWeek == 7 then
dayOfWeek = “Saturday”
end
end

function CalculateDateToDisplay()
if month == 1 then
month = “January”
elseif month == 2 then
month = “February”
elseif month == 3 then
month = “March”
elseif month == 4 then
month = “April”
elseif month == 5 then
month = “May”
elseif month == 6 then
month = “June”
elseif month == 7 then
month = “July”
elseif month == 8 then
month = “August”
elseif month == 9 then
month = “September”
elseif month == 10 then
month = “October”
elseif month == 11 then
month = “November”
elseif month == 12 then
month = “December”
end
end

function CalculateTimeToDisplay()
if hour <= 9 then
hour = tonumber(“0” … hour)
end
if minute <= 9 then
minute = tonumber(“0” … minute)
end
end

AddEventHandler(“playerSpawned”, function()
Citizen.CreateThread(function()
while true do
Wait(1)
year, month, dayOfWeek, hour, minute = GetLocalTime()
timeAndDateString = “|”
CalculateTimeToDisplay()
if displayTime == true then
timeAndDateString = timeAndDateString … " " … hour … “:” … minute … " |"
end
if displayDate == true then
CalculateDateToDisplay()
timeAndDateString = timeAndDateString … " " … dayOfWeek … " " … month … " " … year … " |"
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,0.95)
  	SetTextEntry("STRING")
  	
  	AddTextComponentString(timeAndDateString)
  	DrawText(0.5, 0.01)
  end

end)
end)

Hi, How can I make SYNC the system time with the TIME INGAME. I mean, it’s 00:28 right now, but ingame i have DAYLIGHT … i want it to be 00:28 ingame too :C… help! Thanks!

hi,

I have a question is how do I remove the original time stamp next to the minimap? Also with the speedometer bottom right of the map?

change this:
SetTextWrap(0,0.95)
if you change 0.95 down then it go to the left

example:
SetTextWrap (0.0.18)
this is in the left corner

I hope you understand it.

The Time Syncs With This Script vSync !

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(4)
		SetTextProportional(1)
		SetTextScale(0.50, 0.50)
		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

Video Here:

Hey, I removed the Month and Year thing, I prefer to have only the Hours and Day of the Week but… As the time changes the HUD goes left and right, does anyone know how to make it static ? It’s really annoying and I’ve been on this for hours.