function onPrepareDeath(creature)
local player = creature:getPlayer()
if not player then
return true
end
local amuletItem = player:getSlotItem(CONST_SLOT_NECKLACE)
if not amuletItem or amuletItem:getId() ~= 2196 then
return true
end
player:addHealth(player:getMaxHealth())
player:addMana(player:getMaxMana())
player:teleportTo(player:getTown():getTemplePosition())
amuletItem:remove()
return false
end
Nice!, can u paste here full code?onPrepareDeath script
if amulet == amuletoflife
remove amulet
restore hp/mana
tp to temple
return false
You need to learn how to do things yourself, he pretty much gave you an outline of what you need to do.Nice!, can u paste here full code?
local amulet_slot = 1 --Change the slot number for amulet im to lazy to look it up
function onPrepareDeath(player)
slotItem = player:getSlotItem(1).itemid
if slotItem == 2173 then
player:addHealth(player:getHealthMax())
player:addMana(player:getManaMax())
return false
end
return true
end
Why make an amulet_slot local if you aren't even going to use it?Code:local amulet_slot = 1 --Change the slot number for amulet im to lazy to look it up function onPrepareDeath(player) slotItem = player:getSlotItem(1).itemid if slotItem == 2173 then player:addHealth(player:getHealthMax()) player:addMana(player:getManaMax()) return false end return true end
CONST_SLOT_NECKLACE
also you should change to (player:getMaxX()-player:getX()) to avoid increasing over their current max hp (if thats even possible. but safety i guess, and its getMaxHealth, not getHealthMax)
and dont forget
player:teleportTo(player:getTown():getTemplePosition())
player:removeItem(slotItem, 1) (if only 1 charge, if more charges have to remove charges only)
bumpCode:local amulet_slot = 1 --Change the slot number for amulet im to lazy to look it up function onPrepareDeath(player) slotItem = player:getSlotItem(1).itemid if slotItem == 2173 then player:addHealth(player:getHealthMax()) player:addMana(player:getManaMax()) return false end return true end
<event type="preparedeath"
Login.lua
-- Events
player:registerEvent("Amulet of life
")
bump - this script not working.CONST_SLOT_NECKLACE
also you should change to (player:getMaxX()-player:getX()) to avoid increasing over their current max hp (if thats even possible. but safety i guess, and its getMaxHealth, not getHealthMax)
and dont forget
player:teleportTo(player:getTown():getTemplePosition())
player:removeItem(slotItem, 1) (if only 1 charge, if more charges have to remove charges only)
bumponPrepareDeath script
if amulet == amuletoflife
remove amulet
restore hp/mana
tp to temple
return false
The script remove the Amulet when you die?