-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.lua
More file actions
106 lines (78 loc) · 2.99 KB
/
Copy pathserver.lua
File metadata and controls
106 lines (78 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
firedToday = {}
lastDay = os.date("*t").day
countdownRunning = false
fireworkTimerRunning = false
CreateThread(function()
while true do
local now = os.date("*t")
local lang = Config.Language or "en"
local langTable = Config.Milestones[lang] or Config.Milestones["en"]
-- only at dec 31st
if now.month == 12 and now.day == 31 then
local timeKey = ("%02d:%02d"):format(now.hour, now.min)
if langTable[timeKey] and not firedToday[timeKey] then
TriggerClientEvent("DaFirework:notifyUser", -1, langTable[timeKey])
firedToday[timeKey] = true
-- Countdown bei 23:59
if timeKey == "23:59" and not countdownRunning then
countdownRunning = true
remainingSeconds = 60 - os.date("*t").sec;
TriggerClientEvent("DaFirework:StartCountDown", -1, remainingSeconds, langTable.final)
end
end
else
if now.day ~= lastDay then
firedToday = {}
countdownRunning = false
lastDay = now.day
end
end
Wait(1000)
end
end)
RegisterNetEvent("DaFirework:startFireworkTimer")
AddEventHandler("DaFirework:startFireworkTimer", function()
local src = source
local minutes = (Config and Config.FireworksTime) or 15
if minutes < 1 then minutes = 1 end
if minutes > 120 then minutes = 120 end -- 2h limit
if fireworkTimerRunning then
return
end
fireworkTimerRunning = true
CreateThread(function()
local duration = minutes * 60 * 1000
local startTime = GetGameTimer()
while GetGameTimer() - startTime < duration and fireworkTimerRunning do
Wait(1000)
end
if fireworkTimerRunning then
TriggerClientEvent("DaFirework:stop", -1)
end
fireworkTimerRunning = false
end)
end)
RegisterCommand("firework_countdown", function(source, args, raw)
if source == 0 or IsPlayerAceAllowed(source, "command") then
local lang = Config.Language or "en"
local langTable = Config.Milestones[lang] or Config.Milestones["en"]
local seconds = tonumber(args[1]) or 10
if seconds < 5 then
seconds = 5
end
TriggerClientEvent("DaFirework:StartCountDown", -1, seconds, langTable.final)
print("[DaFirework] countdown manually started.")
end
end, false)
RegisterCommand("firework_start", function(source, args, raw)
if source == 0 or IsPlayerAceAllowed(source, "command") then
TriggerClientEvent("DaFirework:start", -1)
print("[DaFirework] firework manually started.")
end
end, false)
RegisterCommand("firework_stop", function(source, args, raw)
if source == 0 or IsPlayerAceAllowed(source, "command") then
TriggerClientEvent("DaFirework:stop", -1)
print("[DaFirework] firework manually stopped.")
end
end, false)