diff --git a/data-otservbr-global/scripts/actions/other/anniversary_reward_boxes.lua b/data/scripts/actions/items/anniversary_reward_boxes.lua similarity index 92% rename from data-otservbr-global/scripts/actions/other/anniversary_reward_boxes.lua rename to data/scripts/actions/items/anniversary_reward_boxes.lua index 8327222a570..d5d36bb7455 100644 --- a/data-otservbr-global/scripts/actions/other/anniversary_reward_boxes.lua +++ b/data/scripts/actions/items/anniversary_reward_boxes.lua @@ -55,22 +55,24 @@ local config = { } local rewardBox = Action() + function rewardBox.onUse(player, item, fromPosition, itemEx, toPosition) local box = config[item:getId()] - if not box or not player then + if not box then return false end - for i = 1, #box do - if box[i] then - player:addItem(box[i].id, box[i].count) - player:getPosition():sendMagicEffect(CONST_ME_PRISMATIC_SPARK) - end + + for _, reward in ipairs(box) do + player:addItem(reward.id, reward.count) + player:getPosition():sendMagicEffect(CONST_ME_PRISMATIC_SPARK) end + item:remove() return true end -for index, value in pairs(config) do +for index, _ in pairs(config) do rewardBox:id(index) end + rewardBox:register()