local portalId, t = 25058, { ["glacius death"] = { message = "You have defeated Glacius Death!", config = { createPos = {}, -- O portal será criado onde o monstro morrer. toPos = {x = 32202, y = 31863, z = 13}, -- Posição onde o portal irá teleportar portalTime = 1, -- Duração do portal em minutos } }, } --------------------------------------------------------------------------------------- -- Fim da Configuração --------------------------------------------------------------------------------------- local function spectatorStartCountdown(time, position) local spectators = Game.getSpectators(position, false, false, 5, 5, 5, 5) if #spectators > 0 then for i = 1, #spectators do if time > 1 then spectators:say("" .. time .. "", TALKTYPE_MONSTER_SAY, false, spectators, position) else spectators:say("Time out!", TALKTYPE_MONSTER_SAY, false, spectators, position) break end end end local portal = Tile(position):getItemById(portalId) if portal then addEvent(spectatorStartCountdown, 1000, time - 1, position) end end local function removePortal(position) local portal = Tile(position):getItemById(portalId) if portal then portal:remove() end end local deathMonsterCreatePortal = CreatureEvent("deathMonsterCreatePortal") function deathMonsterCreatePortal.onDeath(creature, corpse, killer, mostDamageKiller) if not creature:isMonster() or creature:getMaster() then return true end local k = t[creature:getName():lower()] if not k then return true end local pos = creature:getPosition() local cPos = k.config.createPos if next(cPos) == nil then cPos = pos end if Tile(cPos):getItemById(portalId) then return true end local item = Game.createItem(portalId, 1, cPos) if item:isTeleport() then item:setDestination(k.config.toPos) end local pt = k.config.portalTime addEvent(spectatorStartCountdown, 500, pt * 60, cPos) addEvent(removePortal, pt * 60 * 1000, cPos) return true end deathMonsterCreatePortal:type("death") deathMonsterCreatePortal:register() --------------------------------------------------------------------------------------- -- Registrar script onLogin --------------------------------------------------------------------------------------- local monsterDeathLogin = CreatureEvent("monsterDeathLogin") function monsterDeathLogin.onLogin(player) player:registerEvent("deathMonsterCreatePortal") return true end monsterDeathLogin:type("login") monsterDeathLogin:register()




info
Grupo: Campones
Registrado: 05/08/16
Posts: 14
Reputação: +1
Gênero: Masculino
Nessa versão do Canary está depreciada a função onKill... dando aviso no console para usar a onDeath, porém se eu substituo onDeath pelo onKill simplesmente o portal não aparece.
Se eu uso a onKill da esse aviso ao matar qualquer monstro no servidor: [warning] [CreatureEvent::executeOnKill - Creature GOD DreamS target Glacius Death event killMonsterCreatePortal] Deprecated use of onKill event. Use registered onDeath events instead for better performance.
local portalId, t = 25058,
{
["glacius death"] = {
message = "You have defeated Glacius Death!",
config = {
createPos = {}, -- The portal will be created where the monster dies.
toPos = {x = 32202, y = 31863, z = 13}, -- Position where the portal will teleport to
portalTime = 1, -- Duration of the portal in minutes
}
},
}
---------------------------------------------------------------------------------------
-- Config end
---------------------------------------------------------------------------------------
local function spectatorStartCountdown(time, position)
local spectators = Game.getSpectators(position, false, false, 5, 5, 5, 5)
if #spectators > 0 then
for i = 1, #spectators do
if time > 1 then
spectators:say("" .. time .. "", TALKTYPE_MONSTER_SAY, false, spectators, position)
else
spectators:say("Time out!", TALKTYPE_MONSTER_SAY, false, spectators, position)
break
end
end
end
local portal = Tile(position):getItemById(portalId)
if portal then
addEvent(spectatorStartCountdown, 1000, time - 1, position)
end
end
local function removePortal(position)
local portal = Tile(position):getItemById(portalId)
if portal then
portal:remove()
end
end
local killMonsterCreatePortal = CreatureEvent("killMonsterCreatePortal")
function killMonsterCreatePortal.onKill(creature, target)
if not target:isMonster() or target:getMaster() then
return true
end
local player = Player(creature:getGuid())
local k = t[target:getName():lower()]
if not k then
return true
end
local pos, cPos = target:getPosition()
if type(k.config.createPos) == 'table' then
if next(k.config.createPos) == nil then
cPos = pos
else
cPos = k.config.createPos
end
end
if Tile(cPos):getItemById(portalId) then
return true
end
local item = Game.createItem(portalId, 1, cPos)
if item:isTeleport() then
item:setDestination(k.config.toPos)
end
local pt = k.config.portalTime
addEvent(spectatorStartCountdown, 500, pt * 60, cPos)
addEvent(removePortal, pt * 60 * 1000, cPos)
return true
end
killMonsterCreatePortal:type("kill")
killMonsterCreatePortal:register()
---------------------------------------------------------------------------------------
-- Register script onLogin
---------------------------------------------------------------------------------------
local monsterKillLogin = CreatureEvent("monsterKillLogin")
function monsterKillLogin.onLogin(player)
player:registerEvent("killMonsterCreatePortal")
return true
end
monsterKillLogin:type("login")
monsterKillLogin:register()