__zombie = { storage = 3951, pointsStorage = 666, startTime = 0.1, reqNum = 1, reqLvl = 150, positions = { {Position(1234, 1915, 7), Position(1246, 1927, 7)}, {Position(1214, 1933, 7), Position(1264, 1979, 7)}, Position(1243, 1958, 7), Position(1240, 1290, 7) }, zombies = { {15, 'Almost-A-Ghost Gary'}, {20, 'Bone Toothpick'}, {30, 'Underworld Ted'}, {40, 'The Decay of Edmond'}, {50, 'Skullcrusher Montana'} } } __zombie.startEvent = function() local competitors = {getPlayersInRange(__zombie.positions[1][1], __zombie.positions[1][2]), {}} for _, v in pairs(competitors[1]) do if getPlayerLevel(v) > __zombie.reqLvl and getPlayerAccess(v) < 3 then table.insert(competitors[2], v) end end if #competitors[2] < __zombie.reqNum then return __zombie.cancel() end for _, v in pairs(competitors[2]) do doPlayerSendTextMessage(v, MESSAGE_INFO_DESCR, 'Fight together against the zombies. Once you kill one wave - next, stronger wave will rush the event area. There are five waves. Are you strong enough to fight the plague?') doTeleportThing(v, __zombie.positions[3]) doCreatureSetStorage(v, __zombie.storage, 1) registerCreatureEvent(v, 'ZombieDeath') end __zombie.spawnZombies(1) doSetStorage(__zombie.storage, 1) end __zombie.cancel = function() for _, v in pairs(getPlayersInRange(__zombie.positions[1][1], __zombie.positions[1][2])) do doTeleportThing(v, getTownTemplePosition(getPlayerTown(v))) end doEraseStorage(__zombie.storage) doBroadcastMessage('Zombie event has been canceled due to a lack of participants.') end function __zombie.spawnZombies(tier) local p = getArea(__zombie.positions[3], 10, 10) for i = 1, __zombie.zombies[tier][1] do addEvent( function() local v = doCreateMonster(__zombie.zombies[tier][2], p[math.random(#p)], true, false, false) if type(v) == 'number' then doCreatureSay(v, 'Time to punish those who entered our forbidden grounds.', TALKTYPE_MONSTER_SAY) registerCreatureEvent(v, 'ZombieDeath') end end, math.random(5) * 1000 ) end end