Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
- local dungeonIndex = player:getStorageValue(Storage.dungeonSystem.playerDungeon)
- local dungeonDiff = player:getStorageValue(Storage.dungeonSystem.playerDungeonDiff )
- local dungeon = dungeonSystem.dungeons[dungeonIndex]
- local cooldown = dungeonSystem.dungeons[dungeonIndex].cooldown
- local dungeonRewards = dungeon.rewards[getDungeonDiff(player)]
- if player:getStorageValue(Storage.dungeonSystem.dungeonCooldown + dungeonIndex) >= os.time() then
- player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You may have another reward in "..showTimeLeft(player:getStorageValue(Storage.dungeonSystem.dungeonCooldown + dungeonIndex) - os.time(), true))
- item:getPosition():sendMagicEffect(CONST_ME_POFF)
- return true
- end
- -- Give player reward
- local rewardMessage = capAll(getDungeonDiff(player).." "..dungeon.name).." rewards received:"
- local theRewards = ""
- local rewards = {}
- for i = 1, dungeonRewards.rewardRolls do
- local rewardTable = checkRewards(dungeonRewards.rewards, player)
- local rewardKey = getReward(rewardTable)
- local reward = rewardTable[rewardKey]
- giveReward(reward, player)
- rewards[i] = reward
- end
- for i = 1, #rewards do
- local expReward = rewards[i].amount
- local itemReward = {
- item = rewards[i].item,
- count = rewards[i].count,
- }
- local outfitReward = {
- name = rewards[i].name,
- femaleId = rewards[i].femaleId,
- maleId = rewards[i].maleId,
- }
- local addonReward = {
- outfit = rewards[i].outfit,
- femaleId = rewards[i].femaleId,
- maleId = rewards[i].maleId,
- addon = rewards[i].addonNumber,
- }
- local mountReward = {
- name = rewards[i].mountName,
- }
- local moneyReward = {
- count = rewards[i].amount,
- }
- if rewards[i].type == "item" then
- theRewards = theRewards.."\n- "..capAll(getItemName(itemReward.item)).." ["..itemReward.count.."x] "
- elseif rewards[i].type == "experience" then
- theRewards = theRewards.."\n- "..expReward.." Experience Points"
- elseif rewards[i].type == "outfit" then
- theRewards = theRewards.."\n- The "..capAll(outfitReward.name).." Outfit"
- elseif rewards[i].type == "addon" then
- if addonReward.addon == 1 then
- theRewards = theRewards.."\n- The First "..capAll(addonReward.outfit).." Outfit Addon"
- elseif addonReward.addon == 2 then
- theRewards = theRewards.."\n- The Second "..capAll(addonReward.outfit).." Outfit Addon"
- elseif addonReward.addon == 3 then
- theRewards = theRewards.."\n- The Third "..capAll(addonReward.outfit).." Outfit Addon"
- end
- elseif rewards[i].type == "mount" then
- theRewards = theRewards.."\n- The "..capAll(mountReward.name).." Monut"
- elseif rewards[i].type == "money" then
- theRewards = theRewards.."\n- "..moneyReward.count.." gp"
- end
- end
- -- Set cooldowns
- player:showTextDialog(7844, rewardMessage.."\n"..theRewards)
- player:setDungeonCd(dungeonIndex)
- player:setStorageValue(Storage.dungeonSystem.allowReward + dungeonIndex, 0)
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement