local function ServerSave() -- NINHOS [RANDOM] Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_1, math.random(01, #_GLOBAL_RANDOM.NINHOS["FACIL"])) Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_2, math.random(01, #_GLOBAL_RANDOM.NINHOS["MEDIO"])) Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_3, math.random(01, #_GLOBAL_RANDOM.NINHOS["DIFICIL"])) Game.setStorageValue(_GLOBAL_RANDOM.NINHOS["SYSTEM"].NINHO_4, math.random(01, #_GLOBAL_RANDOM.NINHOS["IMPOSSIVEL"])) -- BOOSTER CREATURE for X = 01, #_SYSTEM.TASK.MONSTER do local mathRandom = math.random(01, #_SYSTEM.TASK.MONSTER[X]) if X ~= 07 then Game.setStorageValue(_SYSTEM.TASK.MONSTER[X][00].BOOSTER, _SYSTEM.TASK.MONSTER[X][mathRandom].IMG_ID) end end -- EVENTOS if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) > 0 then if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 03 then -- CRYPTBLOOD Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_1, 00) end if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 11 then -- PILARES DA FORTUNA for X = 01, 05 do 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]) local CHECK_PILLAR = POS_PILLAR:getTopCreature() if CHECK_PILLAR then doRemoveCreature(CHECK_PILLAR:getId()) end Game.createMonster('Pillar of Fortune', _GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_POS[X].POS[01]) end local players = Game.getPlayers() for _, targetPlayer in ipairs(players) do targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "[EVENTO]\nOs Pilares da Fortuna foram adicionadas ao mapa.") end Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[11].PILLAR_STEP, 01) end if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 12 then -- OS ESCOLHIDOS local ClassMonster = {01, 02, 03, 04, 05, 06, 07, 08, 09, 10, 11} local ClassUm = math.random(01, #ClassMonster) Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_1, ClassMonster[ClassUm]) table.remove(ClassMonster, ClassUm) local ClassDois = math.random(01, #ClassMonster) Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_2, ClassMonster[ClassDois]) table.remove(ClassMonster, ClassDois) local ClassTres = math.random(01, #ClassMonster) Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_3, ClassMonster[ClassTres]) table.remove(ClassMonster, ClassTres) Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_4, 00) if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_5) == 01 then Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_5, 02) else Game.setStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_UID_5, 01) end end end -- SAQUEADORES [RANDOM] for SAQUE_RANK = 01, 05 do local Saquear = {} for i = 01, #_GLOBAL_RANDOM.SAQUEADORES[SAQUE_RANK] do table.insert(Saquear, i) end local R_1 = math.random(01, #Saquear) Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][01], Saquear[R_1]) table.remove(Saquear, R_1) table.sort(Saquear) local R_2 = math.random(01, #Saquear) Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][02], Saquear[R_2]) table.remove(Saquear, R_2) table.sort(Saquear) local R_3 = math.random(01, #Saquear) Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][03], Saquear[R_3]) table.remove(Saquear, R_3) table.sort(Saquear) local R_4 = math.random(01, #Saquear) Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][04], Saquear[R_4]) table.remove(Saquear, R_4) table.sort(Saquear) local R_5 = math.random(01, #Saquear) Game.setStorageValue(_GLOBAL_RANDOM.SAQUEADORES[00][01][SAQUE_RANK][05], Saquear[R_5]) table.remove(Saquear, R_5) table.sort(Saquear) end saveServer() --db.query("DELETE FROM `player_storage` WHERE `player_storage`.`value` = 0;") --db.query("DELETE FROM `player_storage` WHERE `player_storage`.`value` = 0 OR `player_storage`.`value` = 100;") Game.broadcastMessage("Todo o servidor foi salvo.") end local function ServerSaveWarning(time) local remaningTime = tonumber(time) - 60000 Game.broadcastMessage("Todo o servidor será salvo em " .. (remaningTime/60000) .." minuto(s). Mantenha-se em um local seguro.", MESSAGE_STATUS_WARNING) if remaningTime > 60000 then addEvent(ServerSaveWarning, 60000, remaningTime) else Game.broadcastMessage("Todo o servidor será salvo em menos de 1 minuto.") addEvent(ServerSave, 60000) end end function onTime(interval) local remaningTime = configManager.getNumber(configKeys.SERVER_SAVE_NOTIFY_DURATION) * 60000 Game.broadcastMessage("Todo o servidor será salvo em " .. (remaningTime/60000) .." minuto(s). Mantenha-se em um local seguro.", MESSAGE_STATUS_WARNING) addEvent(ServerSaveWarning, 60000, remaningTime) return not configManager.getBoolean(configKeys.SERVER_SAVE_SHUTDOWN) end