OTcreator
Active Member
- Joined
- Feb 14, 2022
- Messages
- 425
- Solutions
- 1
- Reaction score
- 44
Hi,
I have console error when i try check player storage on eventcallbacks/monsters/defaultOnDrop.lua
Why can not use storage function?
I have console error when i try check player storage on eventcallbacks/monsters/defaultOnDrop.lua
Why can not use storage function?
Lua:
local ec = EventCallback
ec.onDropLoot = function(self, corpse)
if configManager.getNumber(configKeys.RATE_LOOT) == 0 then
return
end
local player = Player(corpse:getCorpseOwner())
local mType = self:getType()
if not player or player:getStamina() > 840 then
local monsterLoot = mType:getLoot()
for i = 1, #monsterLoot do
-- // NEW CODE
local bonus = player:getStorageValue(1111)
if bonus < os.time() then
local extraPercent = 20
local default = monsterLoot[i].chance
if default < 100000 then
monsterLoot[i].chance = default + ((extraPercent * (default / 1000) / 100) * 1000)
end
end
-- // NEW CODE
local item = corpse:createLootItem(monsterLoot[i])
if not item then
print('[Warning] DropLoot:', 'Could not add loot item to corpse.')
end
end
if player then
local text = ("Loot of %s: %s"):format(mType:getNameDescription(), corpse:getContentDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_LOOT, text)
end
end
else
local text = ("Loot of %s: nothing (due to low stamina)"):format(mType:getNameDescription())
local party = player:getParty()
if party then
party:broadcastPartyLoot(text)
else
player:sendTextMessage(MESSAGE_LOOT, text)
end
end
end
ec:register()