serversave.lua

main 115 lines · 5 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1local function ServerSave()
2 -- NINHOS [RANDOM]
3 Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_1, math.random(01, #_GLOBAL_RANDOM.NINHOS["FACIL"]))
4 Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_2, math.random(01, #_GLOBAL_RANDOM.NINHOS["MEDIO"]))
5 Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_3, math.random(01, #_GLOBAL_RANDOM.NINHOS["DIFICIL"]))
6 Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_4, math.random(01, #_GLOBAL_RANDOM.NINHOS["IMPOSSIVEL"]))
7 -- BOOSTER CREATURE
8 for X = 01, #_SYSTEM.TASK.MONSTER do
9 local mathRandom = math.random(01, #_SYSTEM.TASK.MONSTER[X])
10 if X ~= 07 then
11 Game.setStorageValue(_SYSTEM.TASK.MONSTER[X][00].BOOSTER, _SYSTEM.TASK.MONSTER[X][mathRandom].IMG_ID)
12 end
13 end
14 -- EVENTOS
15 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) > 0 then
16 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 03 then -- CRYPTBLOOD
17 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_1, 00)
18 end
19 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 11 then -- PILARES DA FORTUNA
20 for X = 01, 05 do
21 local POS_PILLAR = Tile(_GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_POS[X].TILE[01], _GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_POS[X].TILE[02], _GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_POS[X].TILE[03])
22 local CHECK_PILLAR = POS_PILLAR:getTopCreature()
23 if CHECK_PILLAR then
24 doRemoveCreature(CHECK_PILLAR:getId())
25 end
26
27 Game.createMonster('Pillar of Fortune', _GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_POS[X].POS[01])
28 end
29
30 local players = Game.getPlayers()
31 for _, targetPlayer in ipairs(players) do
32 targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "[EVENTO]\nOs Pilares da Fortuna foram adicionadas ao mapa.")
33 end
34 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_STEP, 01)
35 end
36 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 12 then -- OS ESCOLHIDOS
37 local ClassMonster = {01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11}
38 local ClassUm = math.random(01, #ClassMonster)
39 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_1, ClassMonster[ClassUm])
40 table.remove(ClassMonster, ClassUm)
41
42 local ClassDois = math.random(01, #ClassMonster)
43 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_2, ClassMonster[ClassDois])
44 table.remove(ClassMonster, ClassDois)
45
46 local ClassTres = math.random(01, #ClassMonster)
47 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_3, ClassMonster[ClassTres])
48 table.remove(ClassMonster, ClassTres)
49
50 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_4, 00)
51 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_5) == 01 then
52 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_5, 02)
53 else
54 Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_5, 01)
55 end
56 end
57 end
58 -- SAQUEADORES [RANDOM]
59 for SAQUE_RANK = 01, 05 do
60 local Saquear = {}
61 for i = 01, #_GLOBAL_RANDOM.SAQUEADORES[SAQUE_RANK] do
62 table.insert(Saquear, i)
63 end
64
65 local R_1 = math.random(01, #Saquear)
66 Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][01], Saquear[R_1])
67 table.remove(Saquear, R_1)
68 table.sort(Saquear)
69
70 local R_2 = math.random(01, #Saquear)
71 Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][02], Saquear[R_2])
72 table.remove(Saquear, R_2)
73 table.sort(Saquear)
74
75 local R_3 = math.random(01, #Saquear)
76 Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][03], Saquear[R_3])
77 table.remove(Saquear, R_3)
78 table.sort(Saquear)
79
80 local R_4 = math.random(01, #Saquear)
81 Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][04], Saquear[R_4])
82 table.remove(Saquear, R_4)
83 table.sort(Saquear)
84
85 local R_5 = math.random(01, #Saquear)
86 Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][05], Saquear[R_5])
87 table.remove(Saquear, R_5)
88 table.sort(Saquear)
89 end
90
91 saveServer()
92 --db.query("DELETE FROM `player_storage` WHERE `player_storage`.`value` = 0;")
93 --db.query("DELETE FROM `player_storage` WHERE `player_storage`.`value` = 0 OR `player_storage`.`value` = 100;")
94 Game.broadcastMessage("Todo o servidor foi salvo.")
95end
96
97local function ServerSaveWarning(time)
98 local remaningTime = tonumber(time) - 60000
99
100
101 if remaningTime > 60000 then
102 addEvent(ServerSaveWarning, 60000, remaningTime)
103 else
104
105 addEvent(ServerSave, 60000)
106 end
107end
108function onTime(interval)
109 local remaningTime = configManager.getNumber(configKeys.SERVER_SAVE_NOTIFY_DURATION) * 60000
110
111
112 addEvent(ServerSaveWarning, 60000, remaningTime)
113 return not configManager.getBoolean(configKeys.SERVER_SAVE_SHUTDOWN)
114end
115
Top