Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
  2.  
  3. local dungeonIndex = player:getStorageValue(Storage.dungeonSystem.playerDungeon)
  4. local dungeonDiff = player:getStorageValue(Storage.dungeonSystem.playerDungeonDiff )
  5. local dungeon = dungeonSystem.dungeons[dungeonIndex]
  6. local cooldown = dungeonSystem.dungeons[dungeonIndex].cooldown
  7. local dungeonRewards = dungeon.rewards[getDungeonDiff(player)]
  8.  
  9. if player:getStorageValue(Storage.dungeonSystem.dungeonCooldown + dungeonIndex) >= os.time() then
  10. player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You may have another reward in "..showTimeLeft(player:getStorageValue(Storage.dungeonSystem.dungeonCooldown + dungeonIndex) - os.time(), true))
  11. item:getPosition():sendMagicEffect(CONST_ME_POFF)
  12. return true
  13. end
  14.  
  15. -- Give player reward
  16. local rewardMessage = capAll(getDungeonDiff(player).." "..dungeon.name).." rewards received:"
  17. local theRewards = ""
  18. local rewards = {}
  19. for i = 1, dungeonRewards.rewardRolls do
  20. local rewardTable = checkRewards(dungeonRewards.rewards, player)
  21. local rewardKey = getReward(rewardTable)
  22. local reward = rewardTable[rewardKey]
  23. giveReward(reward, player)
  24. rewards[i] = reward
  25. end
  26.  
  27. for i = 1, #rewards do
  28. local expReward = rewards[i].amount
  29. local itemReward = {
  30. item = rewards[i].item,
  31. count = rewards[i].count,
  32. }
  33. local outfitReward = {
  34. name = rewards[i].name,
  35. femaleId = rewards[i].femaleId,
  36. maleId = rewards[i].maleId,
  37. }
  38. local addonReward = {
  39. outfit = rewards[i].outfit,
  40. femaleId = rewards[i].femaleId,
  41. maleId = rewards[i].maleId,
  42. addon = rewards[i].addonNumber,
  43. }
  44. local mountReward = {
  45. name = rewards[i].mountName,
  46. }
  47. local moneyReward = {
  48. count = rewards[i].amount,
  49. }
  50. if rewards[i].type == "item" then
  51. theRewards = theRewards.."\n- "..capAll(getItemName(itemReward.item)).." ["..itemReward.count.."x] "
  52. elseif rewards[i].type == "experience" then
  53. theRewards = theRewards.."\n- "..expReward.." Experience Points"
  54. elseif rewards[i].type == "outfit" then
  55. theRewards = theRewards.."\n- The "..capAll(outfitReward.name).." Outfit"
  56. elseif rewards[i].type == "addon" then
  57. if addonReward.addon == 1 then
  58. theRewards = theRewards.."\n- The First "..capAll(addonReward.outfit).." Outfit Addon"
  59. elseif addonReward.addon == 2 then
  60. theRewards = theRewards.."\n- The Second "..capAll(addonReward.outfit).." Outfit Addon"
  61. elseif addonReward.addon == 3 then
  62. theRewards = theRewards.."\n- The Third "..capAll(addonReward.outfit).." Outfit Addon"
  63. end
  64. elseif rewards[i].type == "mount" then
  65. theRewards = theRewards.."\n- The "..capAll(mountReward.name).." Monut"
  66. elseif rewards[i].type == "money" then
  67. theRewards = theRewards.."\n- "..moneyReward.count.." gp"
  68. end
  69. end
  70.  
  71. -- Set cooldowns
  72. player:showTextDialog(7844, rewardMessage.."\n"..theRewards)
  73. player:setDungeonCd(dungeonIndex)
  74. player:setStorageValue(Storage.dungeonSystem.allowReward + dungeonIndex, 0)
  75. return true
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement