• 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!

Need Custom Amulet of Loss (No experience loss)

Tbol

Well-Known Member
Joined
Apr 7, 2019
Messages
625
Reaction score
71
How to make amulet that when you die you wont lose any experience and that amulet would be active for 5deaths and after 5deaths it would remove that amulet.

TFS 1.2
 
You can use this one and change the old function names on the script or add them to your compat.lua then it will work properly.
If you can't do it just post the issues and I will try to help.
 
You can use this one and change the old function names on the script or add them to your compat.lua then it will work properly.
If you can't do it just post the issues and I will try to help.
So by changing old function it will effect main aol but my goal is to create another aol with different functions
 
You can change to any id of your choice
local amulet = 2196
So you mean entire
LUA:
local bless = {1, 2, 3, 4, 5}
local amulet = 2196

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    if (isPlayer(cid) == TRUE) then
        if (getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == amulet) then
            if (getCreatureSkullType(cid) == SKULL_RED or SKULL_BLACK) then
                doCreatureSetDropLoot(cid, FALSE)       
                doSendMagicEffect(getCreaturePosition(cid), CONST_ME_HOLYAREA) 
            end
            if not(getPlayerBlessing(cid, bless[i])) then
                for i = 1, table.maxn(bless) do
                    doPlayerAddBlessing(cid, bless[i])
                end 
            end
        end
    end
    return TRUE
end
should go on compact.lua and just use new amulet item id and thats it?
 
No it should be added on creaturescripts
add it and test
XML:
<event type="preparedeath" name="myaol" script="myaol.lua"/>
 
I tested with TFS 1.3 and its working properly (Shouldn't have much changes from 1.2) Try the above solution and try changing preparedeath to prepareDeath
 
because you didnt include it in login.lua :)
I dont think its needed but i will try
I tested with TFS 1.3 and its working properly (Shouldn't have much changes from 1.2) Try the above solution and try changing preparedeath to prepareDeath
Nah its preparedeath since i have few scripts with preparedeath


EDIT: tried to register in login didnt changed a think still doesnt work
 
Last edited:
LUA:
local config = {
    amuletID = 2196,
    storageKey = 100371
}

function onPrepareDeath(creature, killer)
    local player = Player(creature)
    if not player then
        return
    end
    local amulet = player:getSlotItem(CONST_SLOT_AMULET)
    local storage = player:getStorageValue(config.storageKey)
    if amulet and amulet:getId() == config.amuletID then
        if storage <= 5 then
            player:setDropLoot(false)
            for i = 1, 5 do
                player:addBlessing(i)
            end
            player:setStorageValue(config.storageKey, storage == -1 and 1 or storage + 1)
        else
            amulet:remove()
        end
    end
    return true
end
 
LUA:
local config = {
    amuletID = 2196,
    storageKey = 100371
}

function onPrepareDeath(creature, killer)
    local player = Player(creature)
    if not player then
        return
    end
    local amulet = player:getSlotItem(CONST_SLOT_AMULET)
    local storage = player:getStorageValue(config.storageKey)
    if amulet and amulet:getId() == config.amuletID then
        if storage <= 5 then
            player:setDropLoot(false)
            for i = 1, 5 do
                player:addBlessing(i)
            end
            player:setStorageValue(config.storageKey, storage == -1 and 1 or storage + 1)
        else
            amulet:remove()
        end
    end
    return true
end
Doesnt work, result is same like with old code (losing loot, losing exp)
 
LUA:
local config = {
    amuletID = 2196,
    storageKey = 100371
}

function onPrepareDeath(creature, killer)
    local player = Player(creature)
    if not player then
        print('exit')
        return true
    end
    print(1)
    local amulet = player:getSlotItem(CONST_SLOT_AMULET)
    local storage = player:getStorageValue(config.storageKey)
    if amulet and amulet:getId() == config.amuletID then
        print(2)
        if storage <= 5 then
            print(3)
            player:setDropLoot(false)
            for i = 1, 5 do
                player:addBlessing(i)
            end
            player:setStorageValue(config.storageKey, storage == -1 and 1 or storage + 1)
        else
            print(4)
            amulet:remove()
        end
    end
    print(5)
    return true
end
Show me the output to console.
 
LUA:
local config = {
    amuletID = 2196,
    storageKey = 100371
}

function onPrepareDeath(creature, killer)
    local player = Player(creature)
    if not player then
        print('exit')
        return true
    end
    print(1)
    local amulet = player:getSlotItem(CONST_SLOT_AMULET)
    local storage = player:getStorageValue(config.storageKey)
    if amulet and amulet:getId() == config.amuletID then
        print(2)
        if storage <= 5 then
            print(3)
            player:setDropLoot(false)
            for i = 1, 5 do
                player:addBlessing(i)
            end
            player:setStorageValue(config.storageKey, storage == -1 and 1 or storage + 1)
        else
            print(4)
            amulet:remove()
        end
    end
    print(5)
    return true
end
Show me the output to console.
Output is
1
5
 
You didn't change the amulet id in config, or you're testing with the wrong id.
Yes i did used wrong item id my bad miss seen it, but after changing to right id, everything is same, print is still
1
5

<item id="15687" article="a" name="Royal Band Of Loss">
<attribute key="weight" value="500" />
<attribute key="slotType" value="necklace" />
</item>

local config = {
amuletID = 15687,
storageKey = 100371
}
 
Add print(amulet, amulet and amulet:getId() or nil, config.amuletID) above if amulet and amulet:getId() == config.amuletID then and show me the output again.
 
Back
Top