• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Amulet of Life for tfs 1.2

zxzxzx

New Member
Joined
Mar 12, 2011
Messages
334
Reaction score
3
Hello! I need amulet of life script (when player die he don't loose items, skills, level, amulet teleport player to temple when he die, amulet have 1 charge left.
 
Solution
Player.getSlotItem will return a nil value if the player is not wearing an amulet.
Code:
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?
You need to learn how to do things yourself, he pretty much gave you an outline of what you need to do.
Replace that with functions that you need and your problem will be solved.
Trying to actively learn is much better than asking people for scripts every couple days.
 
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
 
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?
Also you shouldn't even bother doing that anyways since you're only going to use it once as a function arg
 
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)
 
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)

Have an error: event on use not found.
 
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
bump
 
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)
bump - this script not working.
 
Back
Top