-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinit.lua
More file actions
135 lines (110 loc) · 3.61 KB
/
Copy pathinit.lua
File metadata and controls
135 lines (110 loc) · 3.61 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
require('config')
require('locale')
require('dependencies.json')
require('dependencies.storing')
require("staff_data.staff_config")
require('staff_data.staff_commands')
local players = {}
local timeBool = false
local weatherBool = false
local weatherType -- do not touch
hour = Config.Hour
minute = Config.Minute
registerForEvent("init", function()
if Config.TimeSync then
local myData = LoadData("odm_sync", "data/DataTime.json")
if myData ~= nil then
minute = myData._minute
hour = myData._hour
end
syncTime() timeBool = true
end
if Config.WeatherSync then pickWeather() weatherBool = true end
end)
local timeSync = 0
local weatherSync = 0
registerForEvent("update", function(delta) -- Syncing Time/Weather
timeSync = timeSync + delta
weatherSync = weatherSync + delta
if timeSync > Config.TimerToSyncTime and timeBool then
timeSync = 0
syncTime()
end
if weatherSync > Config.TimerToSyncWeather and weatherBool then
weatherSync = 0
pickWeather()
end
end)
function getRandomWeather(myWeatherType)
local randomWeather = math.random(1, #Config.Seasons[myWeatherType])
for _, _weatherType in pairs(Config.Seasons[myWeatherType]) do
if randomWeather == _ then
if weatherType ~= _weatherType then
weatherType = _weatherType
syncWeather(weatherType)
else pickWeather() --print("dbg")
end
end
end
end
function pickWeather()
if not Config.RealTime then
getRandomWeather(Config.WeatherType)
for k,v in pairs(Config.WorldSeason) do
if v == Config.WeatherType then server.world.season = k end
end
else
for month, season in pairs(Config.RLWeather) do
if server.world.month == month then server.world.season = season print(_U("current_season").." "..season) end
end
local myImportantString
if server.world.season == 1 then myImportantString = "Summer"
elseif server.world.season == 2 then myImportantString = "Winter"
elseif server.world.season == 3 then myImportantString = "Autumn"
elseif server.world.season == 4 then myImportantString = "Spring" end
getRandomWeather(myImportantString)
end
end
function syncTime()
print(_U("time_sync"))
if Config.RealTime then
time = os.date('*t')
hour = time.hour
minute = time.min
server.world.day = time.day
server.world.month = time.month
else
minute = minute + 1
if minute > 59 then
minute = 0
if hour >= 23 then
hour = 0
else
hour = hour + 1
end
end
local SaveDataTime = {
_hour = hour,
_minute = minute,
}
SaveData("odm_sync", "data/DataTime.json", SaveDataTime) -- to create function
end
print(_U("time_hour")..hour.." - ".._U("time_minute")..minute)
server.world.hour = hour
server.world.minute = minute
server.world:RpcSet()
end
function syncWeather(weatherType)
print(_U("weather_sync").." "..weatherType)
server.world.weather = weatherType
server.world:RpcSet()
end
-- Notifying player login/quit
registerForEvent("player_joined", function(Player) -- Notify when players join
print(_U("player_joined")..Player.id)
CheckStaff(Player)
UpdateLoggedPlayers(Player)
end)
registerForEvent("player_left", function(Player) -- Notify when players left
print(_U("player_left")..Player.id)
end)