<?xml version="1.0" encoding="UTF-8"?>
<mod name="LMS_Event" version="2.0" author="Hackier" contact="[email protected]" enabled="yes">
<config name="Lms_setup">
<![CDATA[
setup = {
storage = 7532, -- set free storage
eventStorage = 5373, -- set free storage
joinEventStorage = 4534, -- set free storage
countPlayerStorage = 4553, -- set free storage
killStorage = 4656, -- set free storage
exhaustStorage = 6456,
whichEventStorage = 5486,
maxPlayers = 20, -- max players in event
teleportPosLms = {x=880, y=993, z=7}, -- posiotion to which player is teleporting
rewardID = {7958, 11366, 2349, 7450}, -- reward id which player can win (reward is random)
minLvl = 100, -- minimum of level with which player can join to event
pvp = false,
days = {['Tuesday'] = {'21:59:20'},
['Thursday'] = {'21:59:20'},
['Friday'] = {'21:59:20'},
['Sunday'] = {'21:59:20'}},
minPlayers = 9,
-- NEW --
numberOfCreateMonsters = 5,
---------
text = '-PL-\nAby wygrac i otrzymac nagrode, zabij jak najwieksza liczbe zombie przez 20min lub pozostan sam na arenie.\n\n-ENG-\nTo win and get a reward, kill as many zombies for 20 minutes or stay the same in the arena.',
monsterName = {'Scratchclaw', 'Propell Zombie', 'Vile Centurion', 'Mongrel Man', 'Daidalost'}, -- name of monsters which is creating in event
delayTime = 1.0, -- time in which players who joined to event are teleporting to teleport position [[[miuntes]]]
timeToStartEvent = 5, -- time from teleport to start event [[[seconds]]]
timeToStopEvent = 9200 -- [[[seconds]]]
}
room = {fromPos = {x=677, y=914, z=7}, -- left top corner of event room
toPos = {x=713, y=962, z=7} -- right bottom corner of event room
}
]]>
</config>
<lib name="Lms_lib">
<![CDATA[
function doStopEvent()
if getStorage(setup.eventStorage) == 1 then
local playerTable, creatureTable = {}, {}
for x = room.fromPos.x, room.toPos.x do
for y = room.fromPos.y, room.toPos.y do
local n, i = getTileInfo({x=x, y=y, z=7}).creatures, 1
if n ~= 0 then
local v = getThingfromPos({x=x, y=y, z=7, stackpos=i}).uid
while v ~= 0 do
if isPlayer(v) then
table.insert(playerTable, v)
if n == #playerTable then
break
end
elseif isMonster(v) then
table.insert(creatureTable, v)
if n == #creatureTable then
break
end
end
i = i + 1
v = getThingfromPos({x=x, y=y, z=7, stackpos=i}).uid
end
end
end
end
if #playerTable > 1 then
table.sort(playerTable, function(a, b) return (getCreatureStorage(a, setup.killStorage)) > (getCreatureStorage(b, setup.killStorage)) end)
local prize = math.random(#setup.rewardID)
addEvent(doTeleportThing, 200, playerTable[1], getTownTemplePosition(getPlayerTown(playerTable[1])), true)
doCreatureSetStorage(playerTable[1], setup.killStorage, 0)
doPlayerAddItem(playerTable[1], setup.rewardID[prize], 1)
doCreatureAddHealth(playerTable[1], getCreatureMaxHealth(playerTable[1]) - getCreatureHealth(playerTable[1]))
doCreatureAddMana(playerTable[1], getCreatureMaxMana(playerTable[1]) - getCreatureMana(playerTable[1]))
doPlayerSendTextMessage(playerTable[1], MESSAGE_EVENT_ADVANCE, 'You win! Your reward is ' .. getItemNameById(setup.rewardID[prize]) .. '.')
doBroadcastMessage('Zombie Plague Attack have finished. The winner are ' .. getCreatureName(playerTable[1]) .. '. Congratulations.', MESSAGE_EVENT_ADVANCE)
doSetStorage(setup.eventStorage, -1)
db.executeQuery("INSERT INTO `events` (`event_name`, `winner_name`, `won_item`, `time_win`) VALUES (\"Zombie\", \"" .. getCreatureName(playerTable[1]) .. "\", \"" .. getItemNameById(setup.rewardID[prize]) .. "\", " .. getStorage(setup.whichEventStorage) ..");")
for i = 2, #playerTable do
doCreatureAddHealth(playerTable[i], - getCreatureHealth(playerTable[i]) + 1)
doCreatureAddMana(playerTable[i], - getCreatureMana(playerTable[i]))
doTeleportThing(playerTable[i], getTownTemplePosition(getPlayerTown(playerTable[i])))
doPlayerSendTextMessage(playerTable[i], MESSAGE_EVENT_ADVANCE, 'You loss. You have been infected!')
doSendMagicEffect(getThingPos(playerTable[i]), 31)
doCreatureSetStorage(playerTable[i], setup.killStorage, 0)
end
for i = 1, #creatureTable do
if isMonster(creatureTable[i]) then
doRemoveCreature(creatureTable[i])
end
end
doSetStorage(setup.whichEventStorage, getStorage(setup.whichEventStorage) + 1)
elseif #playerTable == 0 then
for i = 1, #creatureTable do
if isMonster(creatureTable[i]) then
doRemoveCreature(creatureTable[i])
end
end
doBroadcastMessage('No one win in Zombie Plague Attack.', MESSAGE_EVENT_ADVANCE)
doSetStorage(setup.eventStorage, -1)
doSetStorage(setup.whichEventStorage, getStorage(setup.whichEventStorage) + 1)
end
end
end
function doStartEventLMS()
doSetStorage(setup.joinEventStorage, -1)
if setup.minPlayers <= getStorage(setup.countPlayerStorage) then
for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, setup.storage) == 1 then
doCreatureSetStorage(cid, setup.storage, -1)
doTeleportThing(cid, setup.teleportPosLms)
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_INFIGHT)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'Get ready. Event start in ' .. setup.timeToStartEvent .. ' sec.')
end
end
addEvent(doSetStorage, setup.timeToStartEvent * 1000, setup.eventStorage, 1)
addEvent(doStopEvent, setup.timeToStopEvent * 1000)
else
for _, cid in ipairs(getPlayersOnline()) do
if getCreatureStorage(cid, setup.storage) == 1 then
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_INFIGHT)
end
end
doBroadcastMessage('Zombie Plague Attack have started beacuse there were enough players.', MESSAGE_EVENT_ADVANCE)
end
doSetStorage(setup.countPlayerStorage, 0)
end
]]>
</lib>
<talkaction words="!zombie" event="script">
<![CDATA[
domodlib("Lms_setup")
function onSay(cid, words, param)
local storage, playerJoined, counter = getCreatureStorage(cid, setup.storage), {}, getStorage(setup.countPlayerStorage)
if getStorage(setup.joinEventStorage) == 1 then
if(param == '') then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'Command param required (say: "!zombie join" or "!zombie leave").')
end
if getPlayerLevel(cid) < setup.minLvl then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not join to event if you do not have a require level. [' .. setup.minLvl .. ']')
end
if getTileInfo(getThingPos(cid)).protection ~= true then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not join to event if are not in protection zone.')
end
if exhaustion.check(cid, setup.exhaustStorage) ~= false then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You must wait: ' .. exhaustion.get(cid, setup.exhaustStorage) .. ' sec')
end
if param == 'join' then
if storage <= 0 then
if counter ~= setup.maxPlayers - 1 then
doSetStorage(setup.countPlayerStorage, 0)
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureStorage(pid, setup.storage) > 0 then
table.insert(playerJoined, pid)
doSetStorage(setup.countPlayerStorage, #playerJoined)
end
end
local count = getStorage(setup.countPlayerStorage)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, count == 0 and 'You are first in event.' or count == 1 and 'There is 1 player in event.' or count > 1 and 'There are '.. count ..' players in event.')
doCreatureSetStorage(cid, setup.storage, 1)
doCreatureSetNoMove(cid, true)
local condition = createConditionObject(CONDITION_INFIGHT,-1)
doAddCondition(cid, condition)
doPlayerPopupFYI(cid, setup.text)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You have joined to event. You can not move until event do not start. Wait patiently for event start.')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'Max players in event have been reached.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You arleady joined to event. Wait patiently for start.')
end
elseif param == 'leave' then
if storage > 0 then
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_INFIGHT)
doCreatureSetStorage(cid, setup.storage, -1)
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, 'You leave from event.')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not leave from event.')
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not join/leave to event yet.')
end
exhaustion.set(cid, setup.exhaustStorage, 5)
return true
end
]]>
</talkaction>
<talkaction words="!startzombie" access="5" event="script">
<![CDATA[
domodlib("Lms_setup")
domodlib("Lms_lib")
function onSay(cid, words, param)
doBroadcastMessage('Zombie Plague Attack will start in ' .. setup.delayTime .. ' min. You can join to event by say "!zombie join".', MESSAGE_EVENT_ADVANCE)
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureStorage(pid, setup.storage) == 1 then
doCreatureSetStorage(pid, setup.storage, -1)
doSetStorage(setup.countPlayerStorage, 0)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
doCreatureSetStorage(pid, setup.killStorage, 0)
end
end
doSetStorage(setup.joinEventStorage, 1)
addEvent(doStartEventLMS, setup.delayTime * 60 * 1000)
return true
end
]]>
</talkaction>
<event type="think" name="LMS_Boss_Event_Start" event="script">
<![CDATA[
domodlib("Lms_setup")
domodlib("Lms_lib")
local daysOpen = {}
for k, v in pairs(setup.days) do
table.insert(daysOpen, k)
end
function onThink(cid, interval)
if isInArray(daysOpen, os.date('%A')) then
if isInArray(setup.days[os.date('%A')], os.date('%X', os.time())) then
if getStorage(setup.joinEventStorage) ~= 1 then
doBroadcastMessage('Zombie Plague Attack will start in ' .. setup.delayTime .. ' min. You can join to event by say "!zombie join".', MESSAGE_EVENT_ADVANCE)
for _, pid in ipairs(getPlayersOnline()) do
if getCreatureStorage(pid, setup.storage) == 1 then
doCreatureSetStorage(pid, setup.storage, -1)
doSetStorage(setup.countPlayerStorage, 0)
doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true)
doCreatureSetStorage(pid, setup.killStorage, 0)
end
end
doSetStorage(setup.joinEventStorage, 1)
addEvent(doStartEventLMS, setup.delayTime * 60 * 1000)
end
end
end
return true
end
]]>
</event>
<globalevent name="LMS_Event_CheckPlayer" interval="1500" event="script">
<![CDATA[
domodlib("Lms_setup")
function onThink(interval, lastExecution)
if getStorage(setup.eventStorage) == 1 then
local playerTable, creatureTable = {}, {}
for x = room.fromPos.x, room.toPos.x do
for y = room.fromPos.y, room.toPos.y do
local n, i = getTileInfo({x=x, y=y, z=7}).creatures, 1
if n ~= 0 then
local v = getThingfromPos({x=x, y=y, z=7, stackpos=i}).uid
while v ~= 0 do
if isPlayer(v) then
table.insert(playerTable, v)
if n == #playerTable then
break
end
elseif isMonster(v) then
table.insert(creatureTable, v)
if n == #creatureTable then
break
end
end
i = i + 1
v = getThingfromPos({x=x, y=y, z=7, stackpos=i}).uid
end
end
end
end
if #playerTable == 1 then
local prize = math.random(#setup.rewardID)
addEvent(doTeleportThing, 200, playerTable[1], getTownTemplePosition(getPlayerTown(playerTable[1])), true)
doPlayerAddItem(playerTable[1], setup.rewardID[prize], 1)
doCreatureSetStorage(playerTable[1], setup.killStorage, 0)
doCreatureAddHealth(playerTable[1], getCreatureMaxHealth(playerTable[1]) - getCreatureHealth(playerTable[1]))
doCreatureAddMana(playerTable[1], getCreatureMaxMana(playerTable[1]) - getCreatureMana(playerTable[1]))
doPlayerSendTextMessage(playerTable[1], MESSAGE_EVENT_ADVANCE, 'You win! Your reward is ' .. getItemNameById(setup.rewardID[prize]) .. '.')
doBroadcastMessage('Zombie Plague Attack have finished. The winner is ' .. getCreatureName(playerTable[1]) .. '. Congratulations.', MESSAGE_EVENT_ADVANCE)
doSetStorage(setup.eventStorage, -1)
db.executeQuery("INSERT INTO `events` (`event_name`, `winner_name`, `won_item`, `time_win`) VALUES (\"Zombie\", \"" .. getCreatureName(playerTable[1]) .. "\", \"" .. getItemNameById(setup.rewardID[prize]) .. "\", " .. getStorage(setup.whichEventStorage) ..");")
for i = 1, #creatureTable do
if isMonster(creatureTable[i]) then
doRemoveCreature(creatureTable[i])
end
end
doSetStorage(setup.whichEventStorage, getStorage(setup.whichEventStorage) + 1)
elseif #playerTable == 0 then
for i = 1, #creatureTable do
if isMonster(creatureTable[i]) then
doRemoveCreature(creatureTable[i])
end
end
doBroadcastMessage('No one win in Zombie Plague Attack.', MESSAGE_EVENT_ADVANCE)
doSetStorage(setup.eventStorage, -1)
doSetStorage(setup.whichEventStorage, getStorage(setup.whichEventStorage) + 1)
end
end
return true
end
]]>
</globalevent>
<globalevent name="LMS_Event_CreateMonster" interval="500" event="script">
<![CDATA[
domodlib("Lms_setup")
function onThink(interval, lastExecution)
if getStorage(setup.eventStorage) == 1 then
local xTable, yTable = {}, {}
for x = room.fromPos.x, room.toPos.x do
for y = room.fromPos.y, room.toPos.y do
table.insert(xTable, x)
table.insert(yTable, y)
end
end
local pos, create = {x=xTable[math.random(#xTable)], y=yTable[math.random(#yTable)], z=7}
local monster = getCreatureByName(setup.monsterName[math.random(#setup.monsterName)])
for q = 1, setup.numberOfCreateMonsters do
if isCreature(monster) then
if doTileQueryAdd(monster, pos) == RETURNVALUE_NOERROR then
doCreateMonster(setup.monsterName[math.random(#setup.monsterName)], pos, false, false, false)
doSendMagicEffect(pos, 66)
end
end
end
end
return true
end
]]>
</globalevent>
<event type="login" name="LMS_login" event="script">
<![CDATA[
domodlib("Lms_setup")
function onLogin(cid)
if getCreatureStorage(cid, setup.storage) == 1 then
doCreatureSetStorage(cid, setup.storage, -1)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true)
doCreatureSetNoMove(cid, false)
doRemoveCondition(cid, CONDITION_INFIGHT)
doCreatureSetStorage(cid, setup.killStorage, 0)
end
registerCreatureEvent(cid, "LMS_Boss_Event_Start")
registerCreatureEvent(cid, "LMS_dead")
registerCreatureEvent(cid, "LMS_kill")
return true
end
]]>
</event>
<event type="statschange" name="LMS_dead" event="script">
<![CDATA[
domodlib("Lms_setup")
function onStatsChange(cid, attacker, type, combat, value)
if type == 1 and getCreatureHealth(cid) <= value then
if isInRange(getThingPos(cid), room.fromPos, room.toPos) then
if isPlayer(cid) then
doCreatureAddHealth(cid, - getCreatureHealth(cid) + 1)
doCreatureAddMana(cid, - getCreatureMana(cid))
addEvent(doTeleportThing, 200, cid, getTownTemplePosition(getPlayerTown(cid)))
doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'You loss. You have been infected.')
doSendAnimatedText(getThingPos(cid), value, TEXTCOLOR_RED)
doSendMagicEffect(getThingPos(cid), 10)
doCreatureSetStorage(cid, setup.killStorage, 0)
return false
end
end
elseif setup.pvp ~= true and type == 1 and isPlayer(attacker) and isPlayer(cid) then
if isInRange(getThingPos(cid), room.fromPos, room.toPos) then
return false
end
end
return true
end
]]>
</event>
<event type="kill" name="LMS_kill" event="script">
<![CDATA[
domodlib("Lms_setup")
function onKill(cid, target, damage, flags)
if isInRange(getThingPos(cid), room.fromPos, room.toPos) then
if isInArray(setup.monsterName, getCreatureName(target)) then
doCreatureSetStorage(cid, setup.killStorage, math.max(0, getCreatureStorage(cid, setup.killStorage) + 1))
end
end
return true
end
]]>
</event>
</mod>