So by changing old function it will effect main aol but my goal is to create another aol with different functionsYou 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.
![]()
Amulet With Bless
I Have One Amulet And I Need When Player Use This, He Win All Bless. Here: function onPrepareDeath(cid, lastHitKiller, mostDamageKiller) if isPlayer(cid) == true then if (getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == 2196) then if (getCreatureSkullType(cid) ==...otland.net
So you mean entireYou can change to any id of your choice
local amulet = 2196
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
Doesnt work, you lose exp, you lose loot. No errors thoNo it should be added on creaturescripts
add it and test
XML:<event type="preparedeath" name="myaol" script="myaol.lua"/>
because you didnt include it in login.luaDoesnt work, you lose exp, you lose loot. No errors tho
preparedeath to prepareDeathI dont think its needed but i will trybecause you didnt include it in login.lua![]()
Nah its preparedeath since i have few scripts with preparedeathI tested with TFS 1.3 and its working properly (Shouldn't have much changes from 1.2) Try the above solution and try changingpreparedeathtoprepareDeath
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 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
IndeedDid you register the preparedeath event's name in login.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
Output isShow 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
You didn't change the amulet id in config, or you're testing with the wrong id.Output is
1
5
Yes i did used wrong item id my bad miss seen it, but after changing to right id, everything is same, print is stillYou didn't change the amulet id in config, or you're testing with the wrong id.
1Addprint(amulet, amulet and amulet:getId() or nil, config.amuletID)aboveif amulet and amulet:getId() == config.amuletID thenand show me the output again.