creaturescripts -> scripts -> protect.lua:
function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
local level = 80
if isPlayer(cid) and getPlayerLevel(cid) < level then
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
doCreatureAddMana(cid, getCreatureMaxMana(cid))
doRemoveConditions(cid, false)
return false
end
return true
end
creaturescripts -> creaturescripts.xml:
<event type="preparedeath" name="ProtectLevel" event="script" value="levelprotection.lua"/>
creaturescripts -> scripts -> login.lua:
registerCreatureEvent(cid, "ProtectLevel")