<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Fire Storm Event" version="8.6" author="Vodkart" contact="" enabled="yes">
<config name="fire_config"><![CDATA[
Fire = {
storages = {172354, 172355}, -- storage Count
players = {min = 5, max = 30}, -- min, max players no evento
minLevel = 100, -- level minimo para entrar no event
rewards = {{2160,10},{12686,1}}, -- premios que vai receber
timeToStartEvent = 30, -- segundos para começar o evento
CheckTime = 5, -- time to check event
teleport = {{x=1005, y=963, z=7}, {x=1504 , y=816, z=7}}, -- posição do teleport, posição para onde o jogador vai
arena = {{x=1482,y=800,z=7},{x=1522,y=834,z=7}} -- posição começo e final da area
}
Fire_Days = {
["Monday"] = {"11:00","14:00"},
["Tuesday"] = {"11:00","14:00"},
["Wednesday"] = {"11:00","14:00"},
["Thursday"] = {"11:00","14:00"},
["Friday"] = {"11:00","14:00"},
["Saturday"] = {"11:00","14:00"},
["Sunday"] = {"11:00","14:00"}
}
function removeFireTp()
local t = getTileItemById(Fire.teleport[1], 1387).uid
return t > 0 and doRemoveItem(t) and doSendMagicEffect(Fire.teleport[1], CONST_ME_POFF)
end
function ZerarStorFire()
setGlobalStorageValue(Fire.storages[1], 0)
setGlobalStorageValue(Fire.storages[2], 0)
end
function getPlayersInFireEvent()
local t = {}
for _, pid in pairs(getPlayersOnline()) do
if isInRange(getPlayerPosition(pid), Fire.arena[1], Fire.arena[2]) then
t[#t+1] = pid
end
end
return t
end
function getFireRewards(cid, items)
local backpack = doPlayerAddItem(cid, 1995, 1) -- backpackID
for _, i_i in ipairs(items) do
local item, amount = i_i[1],i_i[2]
if isItemStackable(item) or amount == 1 then
doAddContainerItem(backpack, item, amount)
else
for i = 1, amount do
doAddContainerItem(backpack, item, 1)
end
end
end
end
function doFireInArea(n)
if #getPlayersInFireEvent() > 1 then
for i = 1, n do
local pos = {x=math.random(Fire.arena[1].x, Fire.arena[2].x), y=math.random(Fire.arena[1].y,Fire.arena[2].y), z=Fire.arena[1].z}
local m = getTopCreature(pos).uid
doSendDistanceShoot({x = pos.x - math.random(4, 6), y = pos.y - 5, z = pos.z}, pos, CONST_ANI_ICE)
addEvent(doSendMagicEffect, 150, pos, CONST_ME_LOSEENERGY)
if m ~= 0 and isPlayer(m) then
doSendMagicEffect(getCreaturePosition(m), CONST_ME_WATERSPLASH)
doCreatureSay(m, "Ooooh", TALKTYPE_ORANGE_1)
local corpse = doCreateItem(3058, 1, getPlayerPosition(m))
doItemSetAttribute(corpse, "description", "You recognize " .. getCreatureName(m) .. ". He was killed by Rain.")
doSendMagicEffect(getPlayerPosition(m), CONST_ME_POFF)
doTeleportThing(m, getTownTemplePosition(getPlayerTown(m)))
doPlayerSendTextMessage(m, MESSAGE_EVENT_ADVANCE, "[The Rain Event] You died from the rain.")
end
end
local x = 2700-(200*n)
addEvent(doFireInArea, x <= 0 and 500 or x, n+1)
elseif #getPlayersInFireEvent() == 1 then
local cid = getPlayersInFireEvent()[1]
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
getFireRewards(cid, Fire.rewards)
doBroadcastMessage("[The Rain Event] O evento terminou. O ganhador do evento foi: ".. getCreatureName(cid).. ". Congratulations!", MESSAGE_EVENT_ADVANCE)
ZerarStorFire()
else
doBroadcastMessage("[The Rain Event] Não houve ganhadores no evento.", MESSAGE_EVENT_ADVANCE)
ZerarStorFire()
end
end
function CheckFireEvent(delay)
if getGlobalStorageValue(Fire.storages[1]) ~= (Fire.players.max+1) then
if delay > 0 and getGlobalStorageValue(Fire.storages[1]) < Fire.players.max then
doBroadcastMessage("[The Rain Event] Vai começar em " .. delay .. " minutos! O teleporte está na sala de eventos e será fechado quando o evento começar!", MESSAGE_STATUS_WARNING)
elseif delay == 0 and getGlobalStorageValue(Fire.storages[1]) < Fire.players.min then
for _, cid in pairs(getPlayersInFireEvent()) do
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
removeFireTp()
doBroadcastMessage("[The Rain Event] O evento não pode começar, devido a poucos jogadores participantes.\n São necessários ao menos " .. Fire.players.min .. " players para iniciar o evento!", MESSAGE_STATUS_WARNING)
ZerarStorFire()
elseif delay == 0 and getGlobalStorageValue(Fire.storages[1]) >= Fire.players.min then
removeFireTp()
doBroadcastMessage("[The Rain Event] Boa Sorte! O evento vai começar em "..Fire.timeToStartEvent.." segundos. Prepare-se!")
addEvent(doFireInArea, Fire.timeToStartEvent*1000, 1)
end
addEvent(CheckFireEvent, 60000, delay-1)
end
end
]]></config>
<globalevent name="Storm_Fire_Start" interval="60000" event="script"><![CDATA[
domodlib('fire_config')
local function getPlayersInArea(fromPos, toPos)
local players = {}
for _, pid in ipairs(getPlayersOnline()) do
if isInRange(getPlayerPosition(pid), fromPos, toPos) then
table.insert(players, pid)
end
end
return players
end
function onThink(interval, lastExecution)
if Fire_Days[os.date("%A")] then
local hrs = tostring(os.date("%X")):sub(1, 5)
if isInArray(Fire_Days[os.date("%A")], hrs) and getGlobalStorageValue(Fire.storages[2]) <= 0 then
local players_tp = getPlayersInArea({x=292,y=114,z=8}, {x=292,y=114,z=8})
if players_tp then
for _, v in next, players_tp do
doTeleportThing(v, getTownTemplePosition(1))
doPlayerSendTextMessage(v, MESSAGE_STATUS_CONSOLE_BLUE, "Não pode ficar no local onde o TP abriu. Você foi teleportado para o templo.")
end
end
local tp = doCreateItem(1387, 1, Fire.teleport[1])
doItemSetAttribute(tp, "aid", 45111)
CheckFireEvent(Fire.CheckTime)
setGlobalStorageValue(Fire.storages[1], 0)
end
end
return true
end]]></globalevent>
<event type="login" name="Storm_Fire_Login" event="script"><![CDATA[
domodlib('fire_config')
function onLogin(cid)
registerCreatureEvent(cid, "FireStormBatle")
if isInRange(getPlayerPosition(cid), Fire.arena[1], Fire.arena[2]) then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
end
return true
end]]></event>
<event type="combat" name="FireStormBatle" event="script"><![CDATA[
domodlib('fire_config')
if isPlayer(cid) and isPlayer(target) and isInRange(getPlayerPosition(cid), Fire.arena[1], Fire.arena[2]) then
doPlayerSendCancel(cid, "You may not attack this player.")
return false
end
return true
]]></event>
<movevent type="StepIn" actionid ="45111" event="script"><![CDATA[
domodlib('fire_config')
local areaTheRain = {
[1] = {{x = 612, y = 165, z = 7}, {x = 653, y = 199, z = 7}}
}
function onStepIn(cid, item, position, fromPosition)
if not isPlayer(cid) then return true end
if getPlayerAccess(cid) > 3 then return doTeleportThing(cid, Fire.teleport[2]) end
if getPlayerLevel(cid) < Fire.minLevel then
doTeleportThing(cid, fromPosition, true)
doPlayerSendCancel(cid, "[The Rain Event] Você precisa estar pelo menos level " .. Fire.minLevel .. " para participar do evento.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
return true
end
for _, v in pairs(areaTheRain) do
for _, pid in pairs(getPlayersOnline()) do
if (getPlayerIp(pid) == getPlayerIp(cid) and isInRange(getThingPos(pid), v[1], v[2])) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Só é permitido 1 jogador por IP no evento.")
doTeleportThing(cid, fromPosition, false)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
return true
end
end
end
if getGlobalStorageValue(Fire.storages[1]) <= Fire.players.max then
doTeleportThing(cid, Fire.teleport[2])
setGlobalStorageValue(Fire.storages[1], getGlobalStorageValue(Fire.storages[1])+1)
doBroadcastMessage("[The Rain Event] " .. getPlayerName(cid) .. " entrou no evento! Atualmente o evento está com " .. getGlobalStorageValue(Fire.storages[1]) .. " players!", MESSAGE_STATUS_CONSOLE_RED)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[The Rain Event] Não seja pego pela chuva. Ganhará o último jogador que sobreviver.")
if getGlobalStorageValue(Fire.storages[1]) == Fire.players.max then
setGlobalStorageValue(Fire.storages[1], getGlobalStorageValue(Fire.storages[1])+1)
removeFireTp()
doBroadcastMessage("[The Rain Event] Evento vai começar em "..Fire.timeToStartEvent.." segundos. Prepare-se!")
addEvent(doFireInArea, Fire.timeToStartEvent*1000, 1)
end
end
return true
end]]></movevent>
<talkaction words="/firestart;!firestart" access="5" event="buffer"><![CDATA[
domodlib('fire_config')
if getGlobalStorageValue(Fire.storages[2]) > 0 then
doPlayerSendCancel(cid, "The event is already starting.") return true
elseif not param or not tonumber(param) then
doPlayerSendCancel(cid, "Use only numbers.") return true
end
local param = tonumber(param) <= 0 and 1 or tonumber(param)
local tp = doCreateItem(1387, 1, Fire.teleport[1])
doItemSetAttribute(tp, "aid", 45111)
CheckFireEvent(tonumber(param))
setGlobalStorageValue(Fire.storages[1], 0)
setGlobalStorageValue(Fire.storages[2], 1)
]]></talkaction>
<globalevent name="FireDebug-Start" type="start" event="buffer"><![CDATA[
domodlib('fire_config')
ZerarStorFire()
return true]]></globalevent>
</mod>