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.
Spoiler
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
Question
martinsleh 1
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()
Link to comment
Share on other sites
4 answers to this question
Recommended Posts