local EVENT_HOUR = 10
local EVENT_MINUTE = 25
local MINUTES_BEFORE_EVENT = 1
local function startEventForPlayer(player)
local minX = 1160
local minY = 1320
local maxX = 1180
local maxY = 1340
local floor = 7
for i = 1, 5 do
local position = Position(math.random(minX, maxX), math.random(minY, maxY), floor)
local tile = Tile(position)
if tile and tile:getItemCount() == 0 and tile:getTopCreature() == nil and tile:getTopDownItem() == nil then
Game.createItem(16102, 1, position)
end
end
local monsterPosition = Position(1167, 1327, 7)
local monster = Game.createMonster("chicken", monsterPosition)
end
local function broadcastEventMessage
for _, player in ipairs(Game.getPlayers()) do
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Wydarzenie rozpocznie się za 1 minute!")
end
end
function onTime(interval)
local currentTime = os.date("*t")
if currentTime.hour == EVENT_HOUR and currentTime.min == (EVENT_MINUTE - MINUTES_BEFORE_EVENT) then
broadcastEventMessage()
elseif currentTime.hour == EVENT_HOUR and currentTime.min == EVENT_MINUTE then
local players = Game.getPlayers()
for _, player in ipairs(players) do
startEventForPlayer(player)
end
end
return true
end