Apollos
Dude who does stuff
Have an onPrepareDeath function for an event, but for some reason the mob is hitting my character again after the creature event is executed and can kill players. I've tried canceling killer target, setting ghost mode, addEvent to unregister event the onPrepareDeath after a few seconds, unregistering PlayerDeath and DropLoot, and maybe some more I can't rememeber. Any help appreciated, been a pain, my brain is now mush.
Lua:
dofile("data/lib/dota_lib.lua")
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
local player = Player(cid)
local killer = Creature(lastHitKiller)
local temple = player:getTown():getTemplePosition()
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:teleportTo(temple)
player:setDirection(SOUTH)
temple:sendMagicEffect(CONST_ME_TELEPORT)
player:removeCondition(CONDITION_OUTFIT)
player:sendTextMessage(19, 'You have been eliminated from the Dota event.')
dota.playerCount = dota.playerCount - 1
addEvent(
function()
player:registerEvent('PlayerDeath')
player:registerEvent('DropLoot')
player:unregisterEvent("dotaPlayerDeath")
player:addHealth(player:getMaxHealth())
end, 2000
)
for i = 1, #dota.blueTeam do
if player:getName() == dota.blueTeam[i] then
dota.blueTeam[i] = nil
end
end
for i = 1, #dota.redTeam do
if player:getName() == dota.redTeam[i] then
dota.redTeam[i] = nil
end
end
if dota.playerCount == 0 then
endDota()
end
return true
end