I’m new to scripting and wanted to make a simple change to:
I wan’t to make it so time only displays when a player is inside a vehicle. I tried the the following:
--local displayTime = true
local useMilitaryTime = true
local displayDayOfWeek = false
local displayDate = false
local timeAndDateString = nil
local hour
local minute
local dayOfWeek
local month
local dayOfMonth
local year
-- Display Time and Date at top right of screen -- format: | 12:13 | Wednesday | January 17, 2017 |
Citizen.CreateThread(function()
while true do
Wait(1)
timeAndDateString = ""
if displayTime == true then
CalculateTimeToDisplay()
timeAndDateString = timeAndDateString .. " " .. hour .. ":" .. minute .. " "
end
if displayDayOfWeek == true then
CalculateDayOfWeekToDisplay()
timeAndDateString = timeAndDateString .. " " .. dayOfWeek .. " |"
end
if displayDate == true then
CalculateDateToDisplay()
timeAndDateString = timeAndDateString .. " " .. month .. " " .. dayOfMonth .. ", " .. year .. " |"
end
SetTextFont(4)
SetTextProportional(1)
SetTextScale(0.4, 0.4)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextDropShadow()
SetTextOutline()
SetTextRightJustify(false)
SetTextWrap(0,0.95)
SetTextEntry("STRING")
AddTextComponentString(timeAndDateString)
DrawText(0.168, 0.893)
end
end)
if IsPedInAnyVehicle(PlayerPed, true) then
displayTime = true
else
displayTime = false
end
Any help would be appreciated!