@Shiuns blz. Já fiz algumas mudanças e conseguir avançar, porém eu não to conseguindo fazer com que a função OnDeath veja a boss_area na tabela t.days, por que a ação irá acontecer depois que o Boss morrer. Alguém ai me dá uma dica..
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Invasion Event" version="1.0" author="Dwarfer" contact="tibiaking.com" enabled="yes">
<config name="Inv_func"><![CDATA[
t = {
tp_id = 1387,
tp_goboss = {time_before = {60, "sec"}, create_pos = {x = 997, y = 1176, z = 7}},
msg_time = true,
tp_goreward = {x = 668, y = 1595, z = 6},
removetp_time = {120, "sec"},
days = {
[{13, "18:06"}] = {name = "Gaz'haragoth", create_pos = {x = 358, y = 996, z = 11}, to_arena = {x = 717, y = 985, z = 7}, remove_time = {true, {60, "sec"}}, boss_area = {{x = 709, y = 961, z = 4}, {x = 725, y = 975, z = 4}}},
[{13, "22:05"}] = {name = "Ferumbras Boss", create_pos = {x = 717, y = 963, z = 4}, to_arena = {x = 717, y = 985, z = 7}, remove_time = {true, {60, "sec"}}, boss_area = {{x = 709, y = 961, z = 4}, {x = 725, y = 975, z = 4}}},
[{16, "18:06"}] = {name = "Gaz'haragoth", create_pos = {x = 358, y = 996, z = 11}, to_arena = {x = 717, y = 985, z = 7}, remove_time = {true, {60, "sec"}}, boss_area = {{x = 709, y = 961, z = 4}, {x = 725, y = 975, z = 4}}}
}}
function mathtime(table) -- by dwarfer
local unit = {"sec", "min", "hour", "day"}
for i, v in pairs(unit) do
if v == table[2] then
return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1)
end
end
return "Error: Bad declaration in mathtime function."
end
function isHour(a, b)
for i, k in pairs(t.days) do
if i[1] == a and i[2] == b then
return true
end
end
return false
end
function getTable(a,b)
for i, k in pairs(t.days) do
if i[1] == a and i[2] == b then
return k
end
end
end
function doRemoveMonster(uid)
if isMonster(uid) then
doBroadcastMessage(getCreatureName(uid) .. " returned to its covil stronger than before!", MESSAGE_EVENT_ADVANCE)
doRemoveCreature(uid)
end
end
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 removeAll(tp_pos, area)
doRemoveItem(getTileItemById(tp_pos,t.tp_id).uid)
local p = getPlayersInArea(area[1], area[2])
if #p > 0 then
for i = 1, #p do
doTeleportThing(p[i], getTownTemplePosition(getPlayerTown(p[i])))
end
end
end]]></config>
<globalevent name="InvasionEvent" interval="60000" event="script"><![CDATA[
domodlib('Inv_func')
function onThink(interval, lastExecution)
if isHour(tonumber(os.date("%d")), os.date("%X", os.time() + mathtime(t.tp_goboss.time_before)):sub(1,5)) then
local m1 = getTable(tonumber(os.date("%d")), os.date("%X", os.time() + mathtime(t.tp_goboss.time_before)):sub(1,5))
if t.msg_time then
doBroadcastMessage("An evil soul seems to be coming to this land. Teleport appeared at Event Room! It will be there for " .. t.tp_goboss.time_before[1] .. " " .. t.tp_goboss.time_before[2] .. ".")
end
doCleanTile(t.tp_goboss.create_pos)
doCreateTeleport(t.tp_id, m1.to_arena, t.tp_goboss.create_pos)
end
if isHour(tonumber(os.date("%d")), os.date("%X"):sub(1,5)) then
local m = getTable(tonumber(os.date("%d")),os.date("%X"):sub(1,5))
doRemoveItem(getTileItemById(t.tp_goboss.create_pos, t.tp_id).uid)
local text = "It will be there for " .. m.remove_time[2][1] .. " " .. m.remove_time[2][2] .."!"
doBroadcastMessage(m.name .. " appeared in the Boss Area. Kill it if you are able to! " .. (m.remove_time[1] == true and text or ""), MESSAGE_EVENT_ADVANCE)
local monster = doSummonCreature(m.name, m.create_pos)
if m.remove_time[1] then
addEvent(doRemoveMonster, mathtime(m.remove_time[2])*1000, monster)
end
end
return true
end]]></globalevent>
<event type="death" name="InvasionBossDeath" event="script"><![CDATA[
domodlib('Inv_func')
function onDeath(cid)
local p = getCreaturePosition(cid)
if isInRange(p, t.boss_area[1], t.boss_area[2]) then
doCreatureSay(cid, "LOST NOW, BUT I WILL BACK HAHAHAHA! Teleport ends in " .. t.removetp_time[1] .." " .. t.removetp_time[2] .. ".", TALKTYPE_ORANGE_1)
addEvent(function()
doCleanTile(p)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doCreateTeleport(t.tp_id, t.tp_goreward,p)
end, 1)
addEvent(removeAll, mathtime(t.removetp_time)*1000, p, t.boss_area)
end
return true
end
]]></event>
</mod>