hello, your resource and private or did you share it?
how can i set the time open drug shop with it? for example i want they OpenMenu at 8:am and close at 10pm?
Hello I made few chabges to the code to allow better control over it and for better performance
-- Display the Date and Time at the top right if true, and top left if false
local toprightDisplay = true
-- Options to what parts to show
local displayTime = true
local displayDayOfWeek = true
local displayDate = true
-- default is 12 hours clock you can change this to true to use the 24 hours clock
local useMilitaryTime = false
local timeAndDateString = nil
local hour
local minute
local dayOfWeek
local month
local dayOfMonth
local year
local monthlist = {
[0] = "January",
[1] = "February",
[2] = "March",
[3] = "April",
[4] = "May",
[5] = "June",
[6] = "July",
[7] = "August",
[8] = "September",
[9] = "October",
[10] = "November",
[11] = "December",
}
local weeklist = {
[0] = "Sunday",
[1] = "Monday",
[2] = "Tuesday",
[3] = "Wednesday",
[4] = "Thursday",
[5] = "Friday",
[6] = "Saturday",
}
-- 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
if toprightDisplay then
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)
else
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
end)
function CalculateTimeToDisplay()
hour = GetClockHours()
minute = GetClockMinutes()
if useMilitaryTime == false then
if hour == 0 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 = weeklist[GetClockDayOfWeek()]
end
function CalculateDateToDisplay()
month = monthlist[GetClockMonth()]
dayOfMonth = GetClockDayOfMonth()
year = GetClockYear()
end
1 Like
@Trung_Nguyen6
You need to add in your Drug shop where you handle the opening of the menu change it to this
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlPressed(0, 177) then
if TriggerEvent("shopOpenned") then
-- here the code to open the Menu
end
end
end
end)
and also you need to add this to this script “TimeandDateDisplay” , be aware that this script "TimeandDateDisplay should run before your DrugShop script in your server.cfg to avoid any troubles
-- Insert open and close time for your Shop here i used the example you stated Open at 8:am and close at 10pm
local shopopenTime = 8
local shopcloseTime = 22
RegisterNetEvent("shopOpenned")
AddEventHandler("shopOpenned", function()
if shopopenTime <= hour and shopcloseTime >= hour then
return true
else return false
end
end)
also make sure to specify this to run the 24 hours time
local useMilitaryTime = true
Hey there! Do you know how to make it go down too?
hey, any luck with moving it down?
How can i move this down?